text
stringlengths 0
2.2M
|
---|
//:
|
//: 4 If 'BSLS_LIBRARYFEATURES_HAS_CPP17_SEARCH_OVERLOAD' is *not* set,
|
//: specify 'using' directives to search for definitions in both the
|
//: 'native_std' and the 'case13' namespaces. Then define an
|
//: an expression using the namespace-unqualified name 'search'. If
|
//: there is a definition in the 'native_std' namespace in addition
|
//: to the one we planted in namespace 'case13', the test driver will
|
//: fail to compile (ambiguity error).
|
//:
|
//: 5 If 'BSLS_LIBRARYFEATURES_HAS_CPP17_SEARCH_FUNCTORS' is *not* set
|
//: set, we do not test for the possible presence of the 'native_std'
|
//: functors, because only one of them may be missing, which we
|
//: cannot test for, or they may be faulty and not indicated for that
|
//: reason.
|
//
|
// Testing:
|
// BSLS_LIBRARYFEATURES_HAS_CPP17_SEARCH_OVERLOAD
|
// BSLS_LIBRARYFEATURES_HAS_CPP17_SEARCH_FUNCTORS
|
// --------------------------------------------------------------------
|
if (verbose) printf(
|
"TESTING 'BSLS_LIBRARYFEATURES_HAS_CPP17_SEARCH_*' MACROS\n"
|
"========================================================\n");
|
if (verbose) {
|
P(u_BSLS_LIBRARYFEATURES_HAS_CPP17_SEARCH_OVERLOAD_defined)
|
P(u_BSLS_LIBRARYFEATURES_HAS_CPP17_SEARCH_FUNCTORS_defined)
|
}
|
case13::SearcherNull searcher;
|
const char needle[] = "world";
|
const char *needleFirst = needle;
|
const char *needleLast = needle + sizeof needle - 1;
|
const char haystack[] = "Hello, world!";
|
const char *haystackFirst = haystack;
|
const char *haystackLast = haystack + sizeof haystack - 1;
|
#if defined(BSLS_LIBRARYFEATURES_HAS_CPP17_SEARCH_OVERLOAD)
|
const char *result = native_std::search(haystackFirst,
|
haystackLast,
|
searcher);
|
ASSERT(haystackLast == result);
|
#else
|
using namespace native_std;
|
using namespace case13;
|
const char *result = search(haystackFirst, haystackLast, searcher);
|
ASSERT(haystackLast == result);
|
(void) needleFirst;
|
(void) needleLast;
|
#endif
|
#if defined(BSLS_LIBRARYFEATURES_HAS_CPP17_SEARCH_FUNCTORS)
|
native_std::default_searcher dftSearcher(needleFirst,
|
needleLast);
|
native_std::boyer_moore_searcher bmSearcher(needleFirst,
|
needleLast);
|
native_std::boyer_moore_horspool_searcher bmhSearcher(needleFirst,
|
needleLast);
|
#endif
|
if (veryVeryVerbose) P(BSLS_PLATFORM_CMP_VERSION);
|
} break;
|
case 12: {
|
// --------------------------------------------------------------------
|
// TESTING 'BSLS_LIBRARYFEATURES_HAS_CPP11_RANGE_FUNCTIONS'
|
//
|
// Concerns:
|
//: 1 The 'BSLS_LIBRARYFEATURES_HAS_CPP11_RANGE_FUNCTIONS' flag is
|
//: defined when the 'begin' and 'end' function templates are
|
//: provided by the native standard library.
|
//:
|
//: 2 The 'BSLS_LIBRARYFEATURES_HAS_CPP11_RANGE_FUNCTIONS' flag is not
|
//: defined unless the 'begin' and 'end' function templates are
|
//: provided by the native standard library.
|
//
|
// Plan:
|
//: 1 Write a test type, 'case13::TestType', that has members 'begin'
|
//: and 'end', returning a correspondingly defined 'iterator_type'.
|
//:
|
//: 2 If the feature macro is defined, explicitly call 'std::begin' and
|
//: 'std::end' to confirm they exist with a compatible signature.
|
//:
|
//: 3 If the feature macro is NOT defined, apply a 'using namespace' to
|
//: both namespaces 'std' and 'case13', and then call 'begin' and
|
//: 'end'. The call will be ambiguous and force a compile-time error
|
//: only if the 'std' functions are also available, indicating that
|
//: the feature macro should be defined.
|
//
|
// Testing:
|
// BSLS_LIBRARYFEATURES_HAS_CPP11_RANGE_FUNCTIONS
|
// --------------------------------------------------------------------
|
if (verbose) printf(
|
"TESTING 'BSLS_LIBRARYFEATURES_HAS_CPP11_RANGE_FUNCTIONS'\n"
|
"========================================================\n");
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.