//===----------------------------------------------------------------------===// // // 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 // //===----------------------------------------------------------------------===// // check that std::__unwrap_iter() returns the correct type #include #include #include #include #include "test_iterators.h" #include "test_macros.h" template using UnwrapT = decltype(std::__unwrap_iter(std::declval())); template using rev_iter = std::reverse_iterator; template using rev_rev_iter = rev_iter >; static_assert(std::is_same, int*>::value, ""); static_assert(std::is_same >, int*>::value, ""); static_assert(std::is_same >, std::reverse_iterator >::value, ""); static_assert(std::is_same >, int*>::value, ""); static_assert(std::is_same > >, int*>::value, ""); static_assert(std::is_same > > >, rev_iter > >::value, ""); static_assert(std::is_same >, random_access_iterator >::value, ""); static_assert(std::is_same > >, rev_iter > >::value, ""); static_assert(std::is_same > >, random_access_iterator >::value, ""); static_assert(std::is_same > > >, rev_iter > >::value, ""); TEST_CONSTEXPR_CXX20 bool test() { std::string str = "Banane"; using Iter = std::string::iterator; assert(std::__unwrap_iter(str.begin()) == str.data()); assert(std::__unwrap_iter(str.end()) == str.data() + str.size()); assert(std::__unwrap_iter(rev_rev_iter(rev_iter(str.begin()))) == str.data()); assert(std::__unwrap_iter(rev_rev_iter(rev_iter(str.end()))) == str.data() + str.size()); return true; } int main(int, char**) { test(); #if TEST_STD_VER > 17 static_assert(test()); #endif return 0; }