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