8#ifndef INCLUDED_BSLMF_ISCONVERTIBLE
9#define INCLUDED_BSLMF_ISCONVERTIBLE
206#include <bslscm_version.h>
226#ifdef BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER
227# include <type_traits>
230#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
234#if defined(BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER) && \
235 !(defined(BSLS_PLATFORM_CMP_MSVC) && BSLS_PLATFORM_CMP_VERSION <= 1900)
240# define BSLMF_ISCONVERTIBLE_USE_NATIVE_TRAITS
245template <
class t_FROM_TYPE,
class t_TO_TYPE>
246struct is_convertible;
248#ifdef BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES
251template <
class t_FROM_TYPE,
class t_TO_TYPE>
253 is_convertible<t_FROM_TYPE, t_TO_TYPE>::value;
265template <
class t_TYPE,
274template <
class t_TYPE>
280#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
281template <
class t_TYPE>
284 typedef t_TYPE && type;
288template <
class t_TYPE>
293#if !defined(BSLS_PLATFORM_CMP_IBM)
294template <
class t_TYPE>
303#ifdef BSLMF_ISCONVERTIBLE_USE_NATIVE_TRAITS
307template <
class t_FROM_TYPE,
class t_TO_TYPE>
311 ::std::is_convertible<
312 typename BloombergLP::bslmf::IsConvertible_CheckComplete<
314 typename BloombergLP::bslmf::IsConvertible_CheckComplete<
315 t_TO_TYPE>::type>::value> {
339#if !defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
342 template <
class t_TYPE>
347 template <
class t_TYPE>
352 template <
class t_TYPE>
357 template <
class t_TYPE>
375template <
class t_FROM_TYPE,
377#if defined(BSLS_PLATFORM_CMP_GNU) || defined(BSLS_PLATFORM_CMP_CLANG)
396#ifdef BSLS_PLATFORM_CMP_MSVC
397# pragma warning(push)
398# pragma warning(disable: 4244)
411#ifdef BSLS_PLATFORM_CMP_MSVC
429#define BSLMF_ISCONVERTIBLE_SAMETYPEVALUE(t_VALUE, \
434 template <class t_TYPE> \
435 struct IsConvertible_Imp<t_FROM, t_TO, t_FROM_FUND, t_TO_FUND> \
436 : bsl::integral_constant<bool, VALUE> { \
443#define BSLMF_ISCONVERTIBLE_VALUE(t_VALUE, \
448 template <class t_FROM_TYPE, class t_TO_TYPE> \
449 struct IsConvertible_Imp<t_FROM, t_TO, t_FROM_FUND, t_TO_FUND> \
450 : bsl::integral_constant<bool, t_VALUE> { \
458#define BSLMF_ISCONVERTIBLE_FORWARD(t_FROM, t_TO, t_FROM_FUND, t_TO_FUND) \
459 template <class t_FROM_TYPE, class t_TO_TYPE> \
460 struct IsConvertible_Imp<t_FROM, t_TO, t_FROM_FUND, t_TO_FUND> \
461 : IsConvertible_Imp<t_FROM, t_TO, 0, 0> { \
468BSLMF_ISCONVERTIBLE_SAMETYPEVALUE(0,
469 const volatile t_TYPE,
473BSLMF_ISCONVERTIBLE_SAMETYPEVALUE(0,
483BSLMF_ISCONVERTIBLE_VALUE(1,
484 const volatile t_FROM_TYPE,
488BSLMF_ISCONVERTIBLE_VALUE(1,
489 volatile t_FROM_TYPE,
499BSLMF_ISCONVERTIBLE_VALUE(1, const t_FROM_TYPE, const t_TO_TYPE&, 1, 1)
500BSLMF_ISCONVERTIBLE_VALUE(1, t_FROM_TYPE, const t_TO_TYPE&, 1, 1)
507BSLMF_ISCONVERTIBLE_FORWARD(const volatile t_FROM_TYPE,
508 const volatile t_TO_TYPE&, 1, 1)
509BSLMF_ISCONVERTIBLE_FORWARD( volatile t_FROM_TYPE,
510 const volatile t_TO_TYPE&, 1, 1)
511BSLMF_ISCONVERTIBLE_FORWARD(const t_FROM_TYPE,
512 const volatile t_TO_TYPE&, 1, 1)
513BSLMF_ISCONVERTIBLE_FORWARD( t_FROM_TYPE,
514 const volatile t_TO_TYPE&, 1, 1)
519BSLMF_ISCONVERTIBLE_FORWARD(const volatile t_FROM_TYPE,
520 volatile t_TO_TYPE&, 1, 1)
521BSLMF_ISCONVERTIBLE_FORWARD( volatile t_FROM_TYPE,
522 volatile t_TO_TYPE&, 1, 1)
523BSLMF_ISCONVERTIBLE_FORWARD(const t_FROM_TYPE,
524 volatile t_TO_TYPE&, 1, 1)
525BSLMF_ISCONVERTIBLE_FORWARD( t_FROM_TYPE,
526 volatile t_TO_TYPE&, 1, 1)
531BSLMF_ISCONVERTIBLE_FORWARD(const volatile t_FROM_TYPE, t_TO_TYPE&, 1, 1)
532BSLMF_ISCONVERTIBLE_FORWARD( volatile t_FROM_TYPE, t_TO_TYPE&, 1, 1)
533BSLMF_ISCONVERTIBLE_FORWARD(const t_FROM_TYPE, t_TO_TYPE&, 1, 1)
534BSLMF_ISCONVERTIBLE_FORWARD( t_FROM_TYPE, t_TO_TYPE&, 1, 1)
539template <class t_FROM_TYPE, class t_TO_TYPE>
551template <
class t_FROM_TYPE,
class t_TO_TYPE>
552struct IsConvertible_Imp<t_FROM_TYPE, t_TO_TYPE, 1, 1>
553 : IsConvertible_Imp<t_FROM_TYPE, double, 0, 0>::type {
563template <
class t_FROM_TYPE,
class t_TO_TYPE>
564struct IsConvertible_Imp<t_FROM_TYPE, t_TO_TYPE, 0, 1>
565 : IsConvertible_Imp<t_FROM_TYPE, double, 0, 0>::type {
575template <
class t_FROM_TYPE,
class t_TO_TYPE>
576struct IsConvertible_Imp<t_FROM_TYPE, t_TO_TYPE, 1, 0>
577 : IsConvertible_Imp<int, t_TO_TYPE, 0, 0>::type {
587#undef BSLMF_ISCONVERTIBLE_SAMETYPEVALUE
588#undef BSLMF_ISCONVERTIBLE_VALUE
589#undef BSLMF_ISCONVERTIBLE_FORWARD
593template <
class t_TO_TYPE>
596 typename bsl::remove_cv<t_TO_TYPE>::type>::type> {
599template <
class t_FROM_TYPE,
class t_TO_TYPE>
602 bsl::is_void<t_FROM_TYPE>::value ||
603 bsl::is_array<t_TO_TYPE>::value ||
604 bsl::is_function<t_TO_TYPE>::value> {
607template <
class t_FROM_TYPE,
class t_TO_TYPE>
610 IsConvertible_IsNeverConvertible<t_FROM_TYPE, t_TO_TYPE>::value,
612 IsConvertible_Imp<t_FROM_TYPE,
613 typename IsConvertible_LazyTrait<t_TO_TYPE>::type> >::
617template <
class t_FROM_TYPE,
class t_TO_TYPE>
620 bsl::is_void<t_TO_TYPE>::value,
621 typename bsl::is_void<t_FROM_TYPE>::type,
622 IsConvertible_FilterNeverConvertible<
623 typename IsConvertible_CheckComplete<t_FROM_TYPE>::type,
624 typename IsConvertible_CheckComplete<t_TO_TYPE>::type> >::type {
644template <
class t_FROM_TYPE,
class t_TO_TYPE>
646: BloombergLP::bslmf::IsConvertible_Conditional<t_FROM_TYPE, t_TO_TYPE>::type {
655template <
class t_TYPE>
667template <
class t_TYPE>
671template <
class t_TYPE>
675template <
class t_TYPE>
679template <
class t_TYPE>
683template <
class t_TYPE>
687template <
class t_TYPE>
691template <
class t_TYPE>
696template <
class t_TYPE>
700template <
class t_TYPE>
704template <
class t_TYPE>
709template <
class t_TYPE>
714template <
class t_TYPE>
718template <
class t_TYPE>
723template <
class t_TYPE>
728template <
class t_TYPE>
737template <
class t_TYPE>
741template <
class t_TYPE>
745template <
class t_TYPE>
749template <
class t_TYPE>
753template <
class t_TYPE>
757template <
class t_TYPE>
761template <
class t_TYPE>
765template <
class t_TYPE>
770template <
class t_TYPE>
774template <
class t_TYPE>
778template <
class t_TYPE>
783template <
class t_TYPE>
788template <
class t_TYPE>
792template <
class t_TYPE>
797template <
class t_TYPE>
802template <
class t_TYPE>
810template <
class t_TYPE>
812: BloombergLP::bslmf::IsConvertible_Conditional<t_TYPE, t_TYPE>::type {
815template <
class t_FROM_TYPE,
class t_TO_TYPE>
819template <
class t_FROM_TYPE,
class t_TO_TYPE>
824template <
class t_FROM_TYPE,
class t_TO_TYPE>
829template <
class t_FROM_TYPE,
class t_TO_TYPE>
831 const volatile t_TO_TYPE&>
839template <
class t_FROM_TYPE>
841 is_pointer<t_FROM_TYPE>::value,
842 typename remove_cv<t_FROM_TYPE>::type,
846template <
class t_FROM_TYPE,
class t_TO_TYPE>
851 typename BloombergLP::bslmf::IsConvertible_Conditional<
852 volatile t_FROM_TYPE,
853 t_TO_TYPE>::type>::type {
864template <
class t_FROM_TYPE,
class t_TO_TYPE>
887template <
class t_FROM_TYPE,
class t_TO_TYPE>
893#ifndef BDE_OPENSOURCE_PUBLICATION
898#ifdef bslmf_IsConvertible
899#undef bslmf_IsConvertible
902#define bslmf_IsConvertible bslmf::IsConvertible
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_INLINE_VARIABLE
Definition bsls_keyword.h:623
Definition bdlb_printmethods.h:283
Definition bdlbb_blob.h:576
Definition bslmf_isconvertible.h:843
Definition bslmf_addlvaluereference.h:126
Definition bslmf_conditional.h:120
Definition bslmf_enableif.h:525
Definition bslmf_integralconstant.h:244
Definition bslmf_isconst.h:144
Definition bslmf_isconvertible.h:646
Definition bslmf_isconvertible.h:867
Definition bslmf_isfunction.h:232
Definition bslmf_isfundamental.h:329
Definition bslmf_isreference.h:137
Definition bslmf_isvoid.h:138
t_TYPE type
Definition bslmf_isconvertible.h:290
t_TYPE & type
Definition bslmf_isconvertible.h:277
Definition bslmf_isconvertible.h:268
@ k_CHECK_COMPLETE
Definition bslmf_isconvertible.h:271
t_TYPE type
Definition bslmf_isconvertible.h:269
Definition bslmf_isconvertible.h:624
Definition bslmf_isconvertible.h:614
Definition bslmf_isconvertible.h:383
@ value
Definition bslmf_isconvertible.h:402
bsl::integral_constant< bool, value > type
Definition bslmf_isconvertible.h:417
Definition bslmf_isconvertible.h:604
Definition bslmf_isconvertible.h:596
Definition bslmf_isconvertible.h:334
Definition bslmf_isconvertible.h:333
char a
Definition bslmf_isconvertible.h:333
Definition bslmf_isconvertible.h:331
static yes_type match(IsConvertible_Match &)
Return yes_type if called on IsConvertible_Match type.
static no_type match(const t_TYPE &)
static no_type match(const volatile t_TYPE &)
static bsl::enable_if< bsl::is_function< t_TYPE >::value, no_type >::type match(t_TYPE &)
Definition bslmf_isconvertible.h:888
Generate a reference to t_TYPE for use in meta-functions.
Definition bslmf_matchanytype.h:189