text
stringlengths
0
2.2M
#include <bsls_bsltestutil.h>
#include <bsls_nullptr.h>
#include <bsls_platform.h>
#include <bsls_nameof.h>
#include <bsls_timeinterval.h>
#include <stdio.h> // 'printf'
#include <stdlib.h> // 'atoi'
using namespace BloombergLP;
//=============================================================================
// TEST PLAN
//-----------------------------------------------------------------------------
// Overview
// --------
// The component under test defines a meta-function,
// 'bsl::is_trivially_copyable' and a template variable
// 'bsl::is_trivially_copyable_v', that determine whether a template parameter
// type is trivially copyable. By default, the meta-function supports a
// restricted set of type categories and can be extended to support other types
// through either template specialization or use of the
// 'BSLMF_NESTED_TRAIT_DECLARATION' macro.
//
// Thus, we need to ensure that the natively supported types are correctly
// identified by the meta-function by testing the meta-function with each of
// the supported type categories. We also need to verify that the
// meta-function can be correctly extended to support other types through
// either of the two supported mechanisms. Finally, we need to test correct
// support for cv-qualified and array types, where the underlying type may be
// trivially copyable.
//
// ----------------------------------------------------------------------------
// PUBLIC CLASS DATA
// [ 1] bsl::is_trivially_copyable::value
// [ 1] bsl::is_trivially_copyable_v
//
// ----------------------------------------------------------------------------
// [ 6] USAGE EXAMPLE
// [ 5] TESTING: 'typedef struct {} X' ISSUE (AIX BUG, {DRQS 153975424})
// [ 2] EXTENDING bsl::is_trivially_copyable
// [ 3] CONCERN: bsl::is_trivially_copyable<bsls::TimeInterval>::value
// [ 4] CONCERN: bsl::is_trivially_copyable<bslmf::Nil>::value
// ============================================================================
// STANDARD BSL ASSERT TEST FUNCTION
// ----------------------------------------------------------------------------
namespace {
int testStatus = 0;
void aSsErT(bool condition, const char *message, int line)
{
if (condition) {
printf("Error " __FILE__ "(%d): %s (failed)\n", line, message);
if (0 <= testStatus && testStatus <= 100) {
++testStatus;
}
}
}
} // close unnamed namespace
// ============================================================================
// STANDARD BSL TEST DRIVER MACRO ABBREVIATIONS
// ----------------------------------------------------------------------------
#define ASSERT BSLS_BSLTESTUTIL_ASSERT
#define ASSERTV BSLS_BSLTESTUTIL_ASSERTV
#define LOOP_ASSERT BSLS_BSLTESTUTIL_LOOP_ASSERT
#define LOOP0_ASSERT BSLS_BSLTESTUTIL_LOOP0_ASSERT
#define LOOP1_ASSERT BSLS_BSLTESTUTIL_LOOP1_ASSERT
#define LOOP2_ASSERT BSLS_BSLTESTUTIL_LOOP2_ASSERT
#define LOOP3_ASSERT BSLS_BSLTESTUTIL_LOOP3_ASSERT
#define LOOP4_ASSERT BSLS_BSLTESTUTIL_LOOP4_ASSERT
#define LOOP5_ASSERT BSLS_BSLTESTUTIL_LOOP5_ASSERT
#define LOOP6_ASSERT BSLS_BSLTESTUTIL_LOOP6_ASSERT
#define Q BSLS_BSLTESTUTIL_Q // Quote identifier literally.
#define P BSLS_BSLTESTUTIL_P // Print identifier and value.
#define P_ BSLS_BSLTESTUTIL_P_ // P(X) without '\n'.
#define T_ BSLS_BSLTESTUTIL_T_ // Print a tab (w/o newline).
#define L_ BSLS_BSLTESTUTIL_L_ // current Line number
// ============================================================================
// DEFECT DETECTION MACROS
// ----------------------------------------------------------------------------
#define BSLMF_ISTRIVIALLYCOPYABLE_NO_NESTED_FOR_ABOMINABLE_FUNCTIONS 1
// At the moment, 'bsl::is_convertible' will give a hard error when invoked
// with an abominable function type, as used in 'DetectNestedTrait'. There
// is a separate patch coming for this, at which point these tests should
// be re-enabled.
#if defined(BSLS_COMPILERFEATURES_SUPPORT_TRAITS_HEADER)
# define BSLMF_ISTRIVIALLYCOPYABLE_USE_NATIVE_ORACLE 1
// 'native_std::is_trivially_copyable' is available as a trusted oracle of