• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016-2021 Antony Polukhin
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 #include <boost/pfr/core.hpp>
7 
8 
9 template <class T1>
test_counts_on_multiple_chars_impl()10 void test_counts_on_multiple_chars_impl() {
11     using boost::pfr::tuple_size_v;
12 
13     struct t1_0 { T1 v1; };
14 #if !defined(__GNUC__) || __GNUC__ != 8
15     // GCC-8 has big problems with this test:
16     //    error: 'constexpr ubiq_constructor::operator Type&() const [with Type = test_counts_on_multiple_chars()::t2*]',
17     //    declared using local type 'test_counts_on_multiple_chars()::t2', is used but never defined [-fpermissive]
18     //
19     // Fixed in GCC-9.
20     static_assert(tuple_size_v<T1*> == 1, "");
21 #endif
22 
23     struct t1_0_1 { t1_0 t1; };
24     static_assert(tuple_size_v<t1_0_1> == 1, "");
25 
26     struct t1_0_2 { t1_0 t1; t1_0 t2; };
27     static_assert(tuple_size_v<t1_0_2> == 2, "");
28 }
29 
30 template <class T>
test_counts_on_multiple_chars()31 void test_counts_on_multiple_chars() {
32     using boost::pfr::tuple_size_v;
33 
34     test_counts_on_multiple_chars_impl<T>();
35 
36     struct t2 { T v1; T v2; };
37     static_assert(tuple_size_v<t2> == 2, "");
38 
39     test_counts_on_multiple_chars_impl<t2>();
40     test_counts_on_multiple_chars_impl<T[2]>();
41 
42     test_counts_on_multiple_chars_impl<T[3]>();
43     test_counts_on_multiple_chars_impl<T[4]>();
44 
45     struct t8 { T v1; T v2; T v3; T v4; T v5; T v6; T v7; T v8; };
46     static_assert(tuple_size_v<t8> == 8, "");
47     test_counts_on_multiple_chars_impl<t8>();
48 }
49 
main()50 int main() {
51     test_counts_on_multiple_chars< BOOST_PFR_RUN_TEST_ON >();
52 }
53 
54