optional_test_empty_braces.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright (C) 2016 Andrzej Krzemienski.
  2. //
  3. // Use, modification, and distribution is subject to the Boost Software
  4. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/lib/optional for documentation.
  8. //
  9. // You are welcome to contact the author at:
  10. // akrzemi1@gmail.com
  11. #include "boost/optional/optional.hpp"
  12. #ifdef __BORLANDC__
  13. #pragma hdrstop
  14. #endif
  15. #include "boost/core/lightweight_test.hpp"
  16. //#ifndef BOOST_OPTIONAL_NO_CONVERTING_ASSIGNMENT
  17. //#ifndef BOOST_OPTIONAL_NO_CONVERTING_COPY_CTOR
  18. using boost::optional;
  19. struct Value
  20. {
  21. explicit Value(int) {}
  22. };
  23. #ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
  24. template <typename T>
  25. void test_brace_init()
  26. {
  27. optional<T> o = {};
  28. BOOST_TEST(!o);
  29. }
  30. template <typename T>
  31. void test_brace_assign()
  32. {
  33. optional<T> o;
  34. o = {};
  35. BOOST_TEST(!o);
  36. }
  37. #endif
  38. int main()
  39. {
  40. #ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
  41. test_brace_init<int>();
  42. test_brace_init<Value>();
  43. test_brace_assign<int>();
  44. test_brace_assign<Value>();
  45. #endif
  46. return boost::report_errors();
  47. }