BDE 4.14.0 Production release
|
Provide a metafunction for substitutability of type references.
This private, subordinate component to bslstl_function provides a Boolean metafunction, bslstl::Function_IsReferenceCompatible
, which allows generic code to determine whether a reference to the first template parameter type (FROM_TYPE
) can be substituted for a reference to the second template parameter type (TO_TYPE
) with no loss of information. By default, this metafunction yields true_type
if FROM_TYPE
is the same as TO_TYPE
; else it yields false_type
. However, this template can be specialized to yield true_type
for other parameters that have compatible references. In practice, this metafunction is used to detect types, such as bdef_Function
, that convert to bsl::function
and wrap it with no additional data members; bslstl::Function_IsReferenceCompatible
would be specialized to yield true_type
for such wrapper types. This metafunction is used within an enable_if
to prevent types that are reference compatible with bsl::function
from matching template parameters in function
constructors and assignment operators, preferring, instead, the non-template overloads for copy and move construction and assignment. Note that reference qualifiers on FROM_TYPE
and TO_TYPE
will cause instantiation to fail; the caller should strip reference qualifiers on FROM_TYPE
and TO_TYPE
before checking for reference compatibility. This component exists solely to provide a transition from bdef_Function
to bsl::function
so that the former can eventually be deprecated and removed. This component should therefore also be considered deprecated and will be removed when bdef_Function
is removed.