array_getfail1.cpp 1.1 KB

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