error_info_impl.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //Copyright (c) 2006-2010 Emil Dotchevski and Reverge Studios, Inc.
  2. //Distributed under the Boost Software License, Version 1.0. (See accompanying
  3. //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #ifndef BOOST_EXCEPTION_CE6983AC753411DDA764247956D89593
  5. #define BOOST_EXCEPTION_CE6983AC753411DDA764247956D89593
  6. #include <boost/config.hpp>
  7. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  8. #include <boost/type_traits/is_nothrow_move_constructible.hpp>
  9. #endif
  10. #include <utility>
  11. #include <string>
  12. #ifndef BOOST_EXCEPTION_ENABLE_WARNINGS
  13. #if defined(__GNUC__) && __GNUC__*100+__GNUC_MINOR__>301
  14. #pragma GCC system_header
  15. #endif
  16. #ifdef __clang__
  17. #pragma clang system_header
  18. #endif
  19. #ifdef _MSC_VER
  20. #pragma warning(push,1)
  21. #endif
  22. #endif
  23. namespace
  24. boost
  25. {
  26. namespace
  27. exception_detail
  28. {
  29. class
  30. error_info_base
  31. {
  32. public:
  33. virtual std::string name_value_string() const = 0;
  34. virtual error_info_base * clone() const = 0;
  35. virtual
  36. ~error_info_base() BOOST_NOEXCEPT_OR_NOTHROW
  37. {
  38. }
  39. };
  40. }
  41. template <class Tag,class T>
  42. class
  43. error_info:
  44. public exception_detail::error_info_base
  45. {
  46. exception_detail::error_info_base *
  47. clone() const
  48. {
  49. return new error_info<Tag,T>(*this);
  50. }
  51. public:
  52. typedef T value_type;
  53. error_info( value_type const & v ):
  54. v_(v)
  55. {
  56. }
  57. #if (__GNUC__*100+__GNUC_MINOR__!=406) //workaround for g++ bug
  58. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  59. error_info( error_info const & x ):
  60. v_(x.v_)
  61. {
  62. }
  63. error_info( T && v ) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible<T>::value):
  64. v_(std::move(v))
  65. {
  66. }
  67. error_info( error_info && x ) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible<T>::value):
  68. v_(std::move(x.v_))
  69. {
  70. }
  71. #endif
  72. #endif
  73. ~error_info() BOOST_NOEXCEPT_OR_NOTHROW
  74. {
  75. }
  76. value_type const &
  77. value() const
  78. {
  79. return v_;
  80. }
  81. value_type &
  82. value()
  83. {
  84. return v_;
  85. }
  86. private:
  87. error_info & operator=( error_info const & );
  88. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  89. error_info & operator=( error_info && x );
  90. #endif
  91. std::string name_value_string() const;
  92. value_type v_;
  93. };
  94. }
  95. #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
  96. #pragma warning(pop)
  97. #endif
  98. #endif