4#include <cppunit/TestFixture.h>
5#include <cppunit/extensions/HelperMacros.h>
17using namespace CPPUNIT_NS;
25struct CountableStruct {
26 int numberOfElements = 42;
64static_assert(!IsDereferencable<string>::value,
"IsDereferencable: negative case");
65static_assert(!IsDereferencable<int>::value,
"IsDereferencable: negative case");
66static_assert(IsDereferencable<string *>::value,
"IsDereferencable: positive case");
67static_assert(IsDereferencable<int *>::value,
"IsDereferencable: positive case");
68static_assert(IsDereferencable<unique_ptr<string>>::value,
"IsDereferencable: positive case");
69static_assert(IsDereferencable<shared_ptr<string>>::value,
"IsDereferencable: positive case");
70static_assert(!IsDereferencable<weak_ptr<string>>::value,
"IsDereferencable: positive case");
72static_assert(!IsIteratable<int>::value,
"IsIterator: negative case");
73static_assert(!IsIteratable<SomeStruct>::value,
"IsIterator: negative case");
74static_assert(IsIteratable<string>::value,
"IsIterator: positive case");
75static_assert(IsIteratable<vector<int>>::value,
"IsIterator: positive case");
76static_assert(IsIteratable<list<string>>::value,
"IsIterator: positive case");
77static_assert(IsIteratable<map<string, string>>::value,
"IsIterator: positive case");
78static_assert(IsIteratable<initializer_list<double>>::value,
"IsIterator: positive case");
79static_assert(!HasSize<SomeStruct>::value,
"HasSize: negative case");
80static_assert(!HasSize<forward_list<SomeStruct>>::value,
"HasSize: negative case");
81static_assert(HasSize<vector<SomeStruct>>::value,
"HasSize: positive case");
82static_assert(HasSize<string>::value,
"HasSize: positive case");
83static_assert(HasSize<CountableStruct>::value,
"HasSize: positive case");
84static_assert(!IsReservable<list<SomeStruct>>::value,
"HasSize: negative case");
85static_assert(IsReservable<vector<SomeStruct>>::value,
"HasSize: positive case");
86static_assert(HasOperatorBool<function<void(
void)>>::value,
"HasOperatorBool: positive case");
87static_assert(!HasOperatorBool<SomeStruct>::value,
"HasOperatorBool: negative case");
119 CPPUNIT_TEST_SUITE_END();
139 auto someString =
"foo"s;
140 auto someSmartPointer = make_unique<string>(
"foo");
The TraitsTest class tests parts of the Traits namespace which can not be evaluated at compile-time.
void testDereferenceMaybe()
Tests whether a smart pointer to a string can be treated like a normal string through the use of dere...
Contains traits for conveniently exploiting SFINAE.
constexpr auto & dereferenceMaybe(T &&value)
Dereferences the specified value if possible; otherwise just returns value itself.
Evaluates to Bool<true> if all specified conditions are true; otherwise evaluates to Bool<false>.
Evaluates to Bool<true> if at least one of the specified conditions is true; otherwise evaluates to B...
Wraps a static boolean constant.
Evaluates to Bool<true> if the specified type is any of the specified types; otherwise evaluates to B...
Evaluates to Bool<true> if the specified type is a C-string (char * or const char *); otherwise evalu...
Evaluates to Bool<true> if the specified type is complete; if the type is only forward-declared it ev...
Evaluates to Bool<true> if the specified type is none of the specified types; otherwise evaluates to ...
Evaluates to Bool<true> if the specified type is based on the specified template; otherwise evaluates...
Evaluates to Bool<true> if the specified type is based on one of the specified templates; otherwise e...
Evaluates to Bool<true> if the specified type is a standard string, standard string view or C-string ...
Evaluates to Bool<true> if none of the specified conditions are true; otherwise evaluates to Bool<fal...
CPPUNIT_TEST_SUITE_REGISTRATION(TraitsTest)
constexpr CountableStruct someStruct