dlr bug
[mcs.git] / docs / ecma334 / 13.4.4.xml
blobcf7f5e52db28f4433bfba27dbc10727fa941f211
1 <?xml version="1.0"?>
2 <clause number="13.4.4" title="User-defined explicit conversions">
3   <paragraph>A user-defined explicit conversion from type S to type T is processed as follows: <list><list_item> Find the set of types, D, from which user-defined conversion operators will be considered. This set consists of S (if S is a class or struct), the base classes of S (if S is a class), T (if T is a class or struct), and the base classes of T (if T is a class). </list_item><list_item> Find the set of applicable user-defined conversion operators, U. This set consists of the user-defined implicit or explicit conversion operators declared by the classes or structs in D that convert from a type encompassing or encompassed by S to a type encompassing or encompassed by T. If U is empty, the conversion is undefined and a compile-time error occurs. </list_item><list_item> Find the most specific source type, SX, of the operators in U: </list_item><list><list_item> If any of the operators in U convert from S, then SX is S. </list_item><list_item> Otherwise, if any of the operators in U convert from types that encompass S, then SX is the most encompassed type in the combined set of source types of those operators. If no most encompassed type can be found, then the conversion is ambiguous and a compile-time error occurs. </list_item><list_item> Otherwise, SX is the most encompassing type in the combined set of source types of the operators in U. If no most encompassing type can be found, then the conversion is ambiguous and a  compile-time error occurs. </list_item></list><list_item> Find the most specific target type, TX, of the operators in U: </list_item><list><list_item> If any of the operators in U convert to T, then TX is T. </list_item><list_item> Otherwise, if any of the operators in U convert to types that are encompassed by T, then TX is the most encompassing type in the combined set of target types of those operators. If no most encompassing type can be found, then the conversion is ambiguous and a compile-time error occurs. </list_item><list_item> Otherwise, TX is the most encompassed type in the combined set of target types of the operators in U. If no most encompassed type can be found, then the conversion is ambiguous and a compile-time error occurs. </list_item></list><list_item> If U contains exactly one user-defined conversion operator that converts from SX to TX, then this is the most specific conversion operator. If no such operator exists, or if more than one such operator exists, then the conversion is ambiguous and a compile-time error occurs. Otherwise, the user-defined conversion is applied: </list_item><list><list_item> If S is not SX, then a standard explicit conversion from S to SX is performed. </list_item><list_item> The most specific user-defined conversion operator is invoked to convert from SX to TX. </list_item><list_item> If TX is not T, then a standard explicit conversion from TX to T is performed. <table_line/>
4 </list_item></list></list></paragraph>
5 </clause>