1/* tests using std::get on boost:array
2 * (C) Copyright Marshall Clow 2012
3 * Distributed under the Boost Software License, Version 1.0. (See
4 * accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
6 */
7
8#include <string>
9#include <iostream>
10#include <boost/array.hpp>
11#include <algorithm>
12#ifndef BOOST_NO_CXX11_HDR_ARRAY
13#include <array>
14#endif
15
16#include <boost/core/lightweight_test_trait.hpp>
17
18namespace {
19
20 #ifndef BOOST_NO_CXX11_HDR_ARRAY
21 template< class T >
22 void RunStdTests()
23 {
24 typedef boost::array< T, 5 > test_type;
25 typedef T arr[5];
26 test_type test_case; // = { 1, 1, 2, 3, 5 };
27
28 T &aRef = std::get<0> ( test_case );
29 BOOST_TEST ( &*test_case.begin () == &aRef );
30
31 const T &caRef = std::get<0> ( test_case );
32 BOOST_TEST ( &*test_case.cbegin () == &caRef );
33 }
34 #endif
35
36 template< class T >
37 void RunBoostTests()
38 {
39 typedef boost::array< T, 5 > test_type;
40 typedef T arr[5];
41 test_type test_case; // = { 1, 1, 2, 3, 5 };
42
43 T &aRef = boost::get<5> ( test_case );
44 BOOST_TEST ( &*test_case.begin () == &aRef );
45 }
46
47}
48
49int main()
50{
51 RunBoostTests< bool >();
52 RunBoostTests< void * >();
53 RunBoostTests< long double >();
54 RunBoostTests< std::string >();
55
56#ifndef BOOST_NO_CXX11_HDR_ARRAY
57 RunStdTests< bool >();
58 RunStdTests< void * >();
59 RunStdTests< long double >();
60 RunStdTests< std::string >();
61#endif
62
63 return boost::report_errors();
64}
65
66

source code of boost/libs/array/test/array_getfail2.cpp