text
stringlengths 0
2.2M
|
---|
typedef struct {
|
// This user-defined type is used to check the expected behaviour for a
|
// 'typedef struct' non-copyable type (checking to make sure we're not
|
// encountering AIX bug {DRQS 153975424}).
|
StructWithCtor x;
|
} TypedefedStructWithNonPodMember;
|
struct NamedStructWithPodMember {
|
// This user-defined type is used to check the expected behaviour for a
|
// 'well-behaved' copyable type.
|
int x;
|
};
|
typedef struct {
|
// This user-defined type is used to check the expected behaviour for a
|
// 'typedef struct' copyable type (checking to make sure we're not
|
// encountering AIX bug {DRQS 153975424}).
|
int x;
|
} TypedefedStructWithPodMember;
|
} // close unnamed namespace
|
namespace bsl {
|
template <>
|
struct is_trivially_copyable<UserDefinedTcTestType> : bsl::true_type {
|
};
|
} // close namespace bsl
|
//=============================================================================
|
// MAIN PROGRAM
|
//-----------------------------------------------------------------------------
|
int main(int argc, char *argv[])
|
{
|
int test = argc > 1 ? atoi(argv[1]) : 0;
|
bool verbose = argc > 2;
|
bool veryVerbose = argc > 3;
|
bool veryVeryVerbose = argc > 4;
|
bool veryVeryVeryVerbose = argc > 5;
|
(void) veryVerbose; // eliminate unused variable warning
|
(void) veryVeryVerbose; // eliminate unused variable warning
|
(void) veryVeryVeryVerbose; // eliminate unused variable warning
|
setbuf(stdout, NULL); // Use unbuffered output
|
printf("TEST " __FILE__ " CASE %d\n", test);
|
switch (test) { case 0:
|
case 6: {
|
// --------------------------------------------------------------------
|
// USAGE EXAMPLE
|
//
|
// Concerns:
|
//: 1 The usage example provided in the component header file compiles,
|
//: links, and runs as shown.
|
//
|
// Plan:
|
//: 1 Incorporate usage example from header into test driver, remove
|
//: leading comment characters, and replace 'assert' with 'ASSERT'.
|
//: (C-1)
|
//
|
// Testing:
|
// USAGE EXAMPLE
|
// --------------------------------------------------------------------
|
if (verbose) printf("\nUSAGE EXAMPLE"
|
"\n=============\n");
|
///Usage
|
///-----
|
// In this section we show intended use of this component.
|
//
|
///Example 1: Verify Whether Types are Trivially Copyable
|
/// - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// Suppose that we want to assert whether a type is trivially copyable.
|
//
|
// First, we define a set of types to evaluate:
|
//..
|
typedef int MyFundamentalType;
|
typedef int& MyFundamentalTypeReference;
|
//
|
// class MyTriviallyCopyableType {
|
// };
|
//
|
// struct MyNonTriviallyCopyableType {
|
// //...
|
// };
|
//..
|
// Then, since user-defined types cannot be automatically evaluated by
|
// 'is_trivially_copyable', we define a template specialization to specify that
|
// 'MyTriviallyCopyableType' is trivially copyable:
|
//..
|
// namespace bsl {
|
//
|
// template <>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.