]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/typedefs.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 21_strings / basic_string_view / requirements / typedefs.cc
1
2 // { dg-do compile { target c++17 } }
3
4 // Copyright (C) 2013-2022 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
11
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
20
21 #include <string_view>
22 #include <testsuite_containers.h>
23
24 namespace __gnu_test
25 {
26 template<typename _Tp1, typename _Tp2>
27 struct traits<std::basic_string_view<_Tp1, _Tp2>> : public traits_base
28 {
29 typedef std::true_type is_container;
30 typedef std::true_type is_reversible;
31 };
32 }
33
34 #include <testsuite_containers.h>
35
36 // Check container for required typedefs.
37
38 __gnu_test::basic_types<std::string_view> t1b;
39 __gnu_test::reversible_types<std::string_view> t1r;
40 typedef typename std::string_view::traits_type traits_type1;
41
42 __gnu_test::basic_types<std::wstring_view> t2b;
43 __gnu_test::reversible_types<std::wstring_view> t2r;
44 typedef typename std::wstring_view::traits_type traits_type2;
45
46 static_assert(std::is_same<std::string_view::pointer, char*>(),
47 "pointer should be value_type*");
48 static_assert(std::is_same<std::string_view::const_pointer, const char*>(),
49 "const_pointer should be const value_type*");
50 static_assert(std::is_same<std::string_view::reference, char&>(),
51 "reference should be value_type&");
52 static_assert(std::is_same<std::string_view::const_reference, const char&>(),
53 "const_reference should be const value_type&");