optional_test_member_T.cpp 812 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright (C) 2014 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. struct Status
  17. {
  18. enum T
  19. {
  20. DISCONNECTED,
  21. CONNECTING,
  22. CONNECTED,
  23. };
  24. T mValue;
  25. };
  26. void test_member_T()
  27. {
  28. boost::optional<Status> x = Status();
  29. x->mValue = Status::CONNECTED;
  30. BOOST_TEST(x->mValue == Status::CONNECTED);
  31. }
  32. int main()
  33. {
  34. test_member_T();
  35. return boost::report_errors();
  36. }