boost_no_cxx17_structured_bindings.ipp 700 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. Copyright 2017 Glen Joseph Fernandes
  3. (glenjofe@gmail.com)
  4. Distributed under Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. */
  8. // MACRO: BOOST_NO_CXX17_STRUCTURED_BINDINGS
  9. // TITLE: C++17 structured bindings
  10. // DESCRIPTION: C++17 structured bindings are not supported.
  11. #include <tuple>
  12. namespace boost_no_cxx17_structured_bindings {
  13. struct P {
  14. int x;
  15. int y;
  16. };
  17. int test()
  18. {
  19. auto [c, d] = std::make_tuple(1, 2);
  20. if (c != 1 || d != 2) {
  21. return 1;
  22. }
  23. auto [a, b] = P{1, 2};
  24. if (a != 1 || b != 2) {
  25. return 1;
  26. }
  27. return 0;
  28. }
  29. } /* boost_no_cxx17_structured_bindings */