error_info_impl.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 UUID_CE6983AC753411DDA764247956D89593
  5. #define UUID_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. #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
  13. #pragma GCC system_header
  14. #endif
  15. #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
  16. #pragma warning(push,1)
  17. #endif
  18. namespace
  19. boost
  20. {
  21. namespace
  22. exception_detail
  23. {
  24. class
  25. error_info_base
  26. {
  27. public:
  28. virtual std::string name_value_string() const = 0;
  29. virtual error_info_base * clone() const = 0;
  30. virtual
  31. ~error_info_base() BOOST_NOEXCEPT_OR_NOTHROW
  32. {
  33. }
  34. };
  35. }
  36. template <class Tag,class T>
  37. class
  38. error_info:
  39. public exception_detail::error_info_base
  40. {
  41. exception_detail::error_info_base *
  42. clone() const
  43. {
  44. return new error_info<Tag,T>(*this);
  45. }
  46. public:
  47. typedef T value_type;
  48. error_info( value_type const & v ):
  49. v_(v)
  50. {
  51. }
  52. #if (__GNUC__*100+__GNUC_MINOR__!=406) //workaround for g++ bug
  53. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  54. error_info( error_info const & x ):
  55. v_(x.v_)
  56. {
  57. }
  58. error_info( T && v ) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible<T>::value):
  59. v_(std::move(v))
  60. {
  61. }
  62. error_info( error_info && x ) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible<T>::value):
  63. v_(std::move(x.v_))
  64. {
  65. }
  66. #endif
  67. #endif
  68. ~error_info() BOOST_NOEXCEPT_OR_NOTHROW
  69. {
  70. }
  71. value_type const &
  72. value() const
  73. {
  74. return v_;
  75. }
  76. value_type &
  77. value()
  78. {
  79. return v_;
  80. }
  81. private:
  82. error_info & operator=( error_info const & );
  83. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  84. error_info & operator=( error_info && x );
  85. #endif
  86. std::string name_value_string() const;
  87. value_type v_;
  88. };
  89. }
  90. #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
  91. #pragma warning(pop)
  92. #endif
  93. #endif