From 333ed0a327d4c8acc807a3d3a0bc333383b35119 Mon Sep 17 00:00:00 2001 From: Eric Friedman Date: Thu, 17 Jul 2003 08:45:31 +0000 Subject: [PATCH] NO_VOID_RETURNS workaround. [SVN r19167] --- include/boost/variant/visitor_ptr.hpp | 48 +++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/include/boost/variant/visitor_ptr.hpp b/include/boost/variant/visitor_ptr.hpp index 4eacb6f..e5fbb22 100644 --- a/include/boost/variant/visitor_ptr.hpp +++ b/include/boost/variant/visitor_ptr.hpp @@ -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 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::type has_void_result; + return execute_impl(operand, has_void_result()); + } + +#endif // BOOST_NO_VOID_RETURNS workaround + }; template