text
stringlengths
0
2.2M
// the correct value for this trait.
#endif
#if defined(BSLS_PLATFORM_CMP_MSVC) && BSLS_PLATFORM_CMP_VERSION < 1910
// The compiler intrinsic older MSVC compilers use to determine whether a
// type is trivially copyable believes reference types may be trivially
// copyable, while the standard states that reference types are never
// trivially copyable types. Similarly, it has problems with volatile
// qualified trivial class types, and a few other cases, so we do not trust
// the native trait, although available, to serve as an oracle on this
// platform.
# undef BSLMF_ISTRIVIALLYCOPYABLE_USE_NATIVE_ORACLE
#endif
#if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION < 100000
# define BSLMF_ISTRIVIALLYCOPYABLE_BAD_NATIVE_ORACLE 1
// The compiler intrinsic gcc uses to determine whether a type is trivially
// copyable rejects volatile-qualified scalars, and will not be fixed until
// gcc 10 is released (next year at the time of authoring this comment).
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85679 for more details.
#endif
// ============================================================================
// TEST DRIVER CONFIGURATION MACROS
// ----------------------------------------------------------------------------
// Enable the macros below to configure specific builds of the test driver for
// manual testing
//#define BSLMF_ISTRIVIALLYCOPYABLE_SHOW_ERROR_FOR_INCOMPLETE_CLASS 1
// Define this macro to test for compile-fail diagnostics instantiating the
// 'is_trivially_copyable' trait for an incomplete class type.
//#define BSLMF_ISTRIVIALLYCOPYABLE_SHOW_ERROR_FOR_INCOMPLETE_UNION 1
// Define this macro to test for compile-fail diagnostics instantiating the
// 'is_trivially_copyable' trait for an incomplete union type.
//=============================================================================
// COMPONENT SPECIFIC MACROS FOR TESTING
//-----------------------------------------------------------------------------
// Each of the macros below test the 'bsl::is_trivially_copyable' trait with a
// set of variations on a type. There are several layers of macros, as object
// types support the full range of variation, but function types cannot form an
// array, nor be cv-qualified. Similarly, 'void' may be cv-qualified, but
// still cannot form an array. As macros are strictly text-substitution we
// must use the appropriate 'add_decoration' traits to transform types in a
// manner that is guaranteed to be syntactically valid. Note that these are
// not type-dependent contexts, so there is no need to use 'typename' when
// fetching the result from any of the queried traits. Valid entry points into
// this system of macros are:
// ASSERT_IS_TRIVIALLY_COPYABLE : single type
// ASSERT_IS_TRIVIALLY_COPYABLE_TYPE : a type, plus pointer/references
// ASSERT_IS_TRIVIALLY_COPYABLE_OBJECT_TYPE : an object type, plus all
// reasonable variations
//
// Macro: ASSERT_IS_TRIVIALLY_COPYABLE_CONSULT_ORACLE
// This macro validates that the 'bsl' trait has the same result as the
// native trait if it is available, and expands to nothing otherwise.
#if defined(BSLMF_ISTRIVIALLYCOPYABLE_USE_NATIVE_ORACLE)
# if defined(BSLMF_ISTRIVIALLYCOPYABLE_BAD_NATIVE_ORACLE)
# define ASSERT_IS_TRIVIALLY_COPYABLE_CONSULT_ORACLE(TYPE) \
{ \
typedef bsl::remove_volatile<TYPE>::type TestType; \
ASSERTV( bsls::NameOf<TYPE>().name(), \
native_std::is_trivially_copyable<TestType>::value, \
bsl ::is_trivially_copyable<TestType>::value, \
native_std::is_trivially_copyable<TestType>::value == \
bsl ::is_trivially_copyable<TestType>::value); \
}
# else
# define ASSERT_IS_TRIVIALLY_COPYABLE_CONSULT_ORACLE(TYPE) \
ASSERTV( bsls::NameOf<TYPE>().name(), \
native_std::is_trivially_copyable<TYPE>::value, \
bsl ::is_trivially_copyable<TYPE>::value, \
native_std::is_trivially_copyable<TYPE>::value == \
bsl ::is_trivially_copyable<TYPE>::value)
// Confirm that the result of 'bsl::is_trivially_copyable<TYPE>' agrees
// with the oracle 'native_std::is_trivially_copyable<TYPE>'.
# endif
#else
# define ASSERT_IS_TRIVIALLY_COPYABLE_CONSULT_ORACLE(TYPE)
// The native trait is not available to act as an oracle, so there is no
// test to perform.
#endif
// Macro: ASSERT_VARIABLE_TEMPLATE_IS_CONSISTENT
// This macro validates that the 'bsl' variable template has the same value
// as the associated trait, if variable templates are supported by the
// compiler, and expands to nothing otherwise.
#if defined(BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES)
# define ASSERT_VARIABLE_TEMPLATE_IS_CONSISTENT(TYPE) \
ASSERT( bsl::is_trivially_copyable <TYPE>::value == \
bsl::is_trivially_copyable_v<TYPE>)
// 'ASSERT' that 'is_trivially_copyable_v' has the same value as
// 'is_trivially_copyable::value'.
#else
# define ASSERT_VARIABLE_TEMPLATE_IS_CONSISTENT(TYPE)