//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // struct iterator_traits // { // }; #include #include #include "test_macros.h" template using always_void = void; #define HAS_XXX(member) \ template \ struct has_##member : std::false_type {}; \ template \ struct has_##member > : std::true_type {} HAS_XXX(difference_type); HAS_XXX(value_type); HAS_XXX(pointer); HAS_XXX(reference); HAS_XXX(iterator_category); struct A {}; struct NotAnIteratorEmpty {}; struct NotAnIteratorNoDifference { // typedef int difference_type; typedef A value_type; typedef A* pointer; typedef A& reference; typedef std::forward_iterator_tag iterator_category; }; struct NotAnIteratorNoValue { typedef int difference_type; // typedef A value_type; typedef A* pointer; typedef A& reference; typedef std::forward_iterator_tag iterator_category; }; struct NotAnIteratorNoPointer { typedef int difference_type; typedef A value_type; // typedef A* pointer; typedef A& reference; typedef std::forward_iterator_tag iterator_category; }; struct NotAnIteratorNoReference { typedef int difference_type; typedef A value_type; typedef A* pointer; // typedef A& reference; typedef std::forward_iterator_tag iterator_category; }; struct NotAnIteratorNoCategory { typedef int difference_type; typedef A value_type; typedef A* pointer; typedef A& reference; // typedef std::forward_iterator_tag iterator_category; }; void test() { { typedef std::iterator_traits T; static_assert(!has_difference_type::value, ""); static_assert(!has_value_type::value, ""); static_assert(!has_pointer::value, ""); static_assert(!has_reference::value, ""); static_assert(!has_iterator_category::value, ""); } { typedef std::iterator_traits T; static_assert(!has_difference_type::value, ""); static_assert(!has_value_type::value, ""); static_assert(!has_pointer::value, ""); static_assert(!has_reference::value, ""); static_assert(!has_iterator_category::value, ""); } { typedef std::iterator_traits T; static_assert(!has_difference_type::value, ""); static_assert(!has_value_type::value, ""); static_assert(!has_pointer::value, ""); static_assert(!has_reference::value, ""); static_assert(!has_iterator_category::value, ""); } #if TEST_STD_VER <= 17 || !defined(__cpp_lib_concepts) { typedef std::iterator_traits T; static_assert(!has_difference_type::value, ""); static_assert(!has_value_type::value, ""); static_assert(!has_pointer::value, ""); static_assert(!has_reference::value, ""); static_assert(!has_iterator_category::value, ""); } #endif // TEST_STD_VER <= 17 || !defined(__cpp_lib_concepts) { typedef std::iterator_traits T; static_assert(!has_difference_type::value, ""); static_assert(!has_value_type::value, ""); static_assert(!has_pointer::value, ""); static_assert(!has_reference::value, ""); static_assert(!has_iterator_category::value, ""); } { typedef std::iterator_traits T; static_assert(!has_difference_type::value, ""); static_assert(!has_value_type::value, ""); static_assert(!has_pointer::value, ""); static_assert(!has_reference::value, ""); static_assert(!has_iterator_category::value, ""); } }