Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / array / test / array_getfail1.cpp
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 <boost/array.hpp>
9 #include <boost/static_assert.hpp>
10
11
12 #include <string>
13 #include <iostream>
14 #include <algorithm>
15 #ifndef BOOST_NO_CXX11_HDR_ARRAY
16 #include <array>
17 #endif
18
19 #include <boost/core/lightweight_test_trait.hpp>
20
21 namespace {
22
23     #ifndef BOOST_NO_CXX11_HDR_ARRAY
24     template< class T >
25     void    RunStdTests()
26     {
27         typedef boost::array< T, 5 >    test_type;
28         typedef T arr[5];
29         test_type           test_case; //   =   { 1, 1, 2, 3, 5 };
30     
31         T &aRef = std::get<5> ( test_case );    // should fail to compile
32         BOOST_TEST ( &*test_case.begin () == &aRef );
33     }
34     #endif
35
36 }
37
38 int main()
39 {
40 #ifndef BOOST_NO_CXX11_HDR_ARRAY
41     RunStdTests< bool >();
42     RunStdTests< void * >();
43     RunStdTests< long double >();
44     RunStdTests< std::string >();
45 #else
46     BOOST_STATIC_ASSERT ( false );  // fail on C++03 systems.
47 #endif
48
49     return boost::report_errors();
50 }