//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // // __libcpp_is_trivial_iterator // __libcpp_string_gets_noexcept_iterator determines if an iterator can be used // w/o worrying about whether or not certain operations can throw. // This gives us a "fast path for string operations" // #include #include #include #include #include #include "test_macros.h" #include "test_iterators.h" #ifndef TEST_HAS_NO_EXCEPTIONS static const bool expected = false; #else // Under libcpp-no-exceptions all noexcept expressions are trivially true, so // any check for a noexcept returning false must actually check for it being // true. static const bool expected = true; #endif int main() { // basic tests static_assert(( std::__libcpp_string_gets_noexcept_iterator::value), ""); static_assert(( std::__libcpp_string_gets_noexcept_iterator::value), ""); static_assert(( std::__libcpp_string_gets_noexcept_iterator > ::value), ""); static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); static_assert(( std::__libcpp_string_gets_noexcept_iterator > ::value), ""); static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); static_assert(( std::__libcpp_string_gets_noexcept_iterator > ::value), ""); static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); static_assert(( std::__libcpp_string_gets_noexcept_iterator > > ::value), ""); // iterators in the libc++ test suite static_assert(std::__libcpp_string_gets_noexcept_iterator >::value == expected, ""); static_assert(std::__libcpp_string_gets_noexcept_iterator >::value == expected, ""); static_assert(std::__libcpp_string_gets_noexcept_iterator >::value == expected, ""); static_assert(std::__libcpp_string_gets_noexcept_iterator >::value == expected, ""); static_assert(std::__libcpp_string_gets_noexcept_iterator >::value == expected, ""); static_assert(std::__libcpp_string_gets_noexcept_iterator >::value == expected, ""); #if TEST_STD_VER >= 11 static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); #else static_assert(std::__libcpp_string_gets_noexcept_iterator >::value == expected, ""); #endif // // iterators from libc++'s containers // // string static_assert(( std::__libcpp_string_gets_noexcept_iterator::iterator> ::value), ""); static_assert(( std::__libcpp_string_gets_noexcept_iterator::const_iterator> ::value), ""); static_assert(( std::__libcpp_string_gets_noexcept_iterator::reverse_iterator> ::value), ""); static_assert(( std::__libcpp_string_gets_noexcept_iterator::const_reverse_iterator>::value), ""); // vector static_assert(( std::__libcpp_string_gets_noexcept_iterator::iterator> ::value), ""); static_assert(( std::__libcpp_string_gets_noexcept_iterator::const_iterator> ::value), ""); static_assert(( std::__libcpp_string_gets_noexcept_iterator::reverse_iterator> ::value), ""); static_assert(( std::__libcpp_string_gets_noexcept_iterator::const_reverse_iterator>::value), ""); #if TEST_STD_VER >= 11 // Initializer list (which has no reverse iterators) static_assert(( std::__libcpp_string_gets_noexcept_iterator::iterator> ::value), ""); static_assert(( std::__libcpp_string_gets_noexcept_iterator::const_iterator> ::value), ""); #endif }