mirror of
https://github.com/boostorg/variant.git
synced 2026-02-11 12:22:11 +00:00
NO_VOID_RETURNS workaround.
[SVN r19167]
This commit is contained in:
@@ -21,8 +21,9 @@
|
||||
|
||||
#include "boost/mpl/apply_if.hpp"
|
||||
#include "boost/mpl/identity.hpp"
|
||||
#include "boost/type_traits/is_reference.hpp"
|
||||
#include "boost/type_traits/add_reference.hpp"
|
||||
#include "boost/type_traits/is_reference.hpp"
|
||||
#include "boost/type_traits/is_void.hpp"
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -35,12 +36,14 @@ namespace boost {
|
||||
struct bad_visit
|
||||
: std::exception
|
||||
{
|
||||
public:
|
||||
public: // std::exception interface
|
||||
|
||||
virtual const char * what() const throw()
|
||||
{
|
||||
return "boost::bad_visit: "
|
||||
"failed visitation using boost::apply_visitor";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -81,17 +84,48 @@ public: // structors
|
||||
|
||||
public: // static visitor interfaces
|
||||
|
||||
result_type operator()(argument_fwd_type operand) const
|
||||
{
|
||||
return visitor_(operand);
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
result_type operator()(const U&) const
|
||||
{
|
||||
throw bad_visit();
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_VOID_RETURNS)
|
||||
|
||||
public: // static visitor interfaces, cont.
|
||||
|
||||
result_type operator()(argument_fwd_type operand) const
|
||||
{
|
||||
return visitor_(operand);
|
||||
}
|
||||
|
||||
#else // defined(BOOST_NO_VOID_RETURNS)
|
||||
|
||||
private: // helpers, for static visitor interfaces (below)
|
||||
|
||||
result_type execute_impl(argument_fwd_type operand, mpl::false_) const
|
||||
{
|
||||
return visitor_(operand);
|
||||
}
|
||||
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(void)
|
||||
execute_impl(argument_fwd_type operand, mpl::true_) const
|
||||
{
|
||||
visitor_(operand);
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
public: // static visitor interfaces, cont.
|
||||
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
operator()(argument_fwd_type operand) const
|
||||
{
|
||||
typedef typename is_void<result_type>::type has_void_result;
|
||||
return execute_impl(operand, has_void_result());
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_VOID_RETURNS workaround
|
||||
|
||||
};
|
||||
|
||||
template <typename R, typename T>
|
||||
|
||||
Reference in New Issue
Block a user