source: NonGTP/Boost/boost/variant/detail/apply_visitor_unary.hpp @ 857

Revision 857, 2.3 KB checked in by igarcia, 19 years ago (diff)
Line 
1//-----------------------------------------------------------------------------
2// boost variant/detail/apply_visitor_unary.hpp header file
3// See http://www.boost.org for updates, documentation, and revision history.
4//-----------------------------------------------------------------------------
5//
6// Copyright (c) 2002-2003
7// Eric Friedman
8//
9// Distributed under the Boost Software License, Version 1.0. (See
10// accompanying file LICENSE_1_0.txt or copy at
11// http://www.boost.org/LICENSE_1_0.txt)
12
13#ifndef BOOST_VARIANT_DETAIL_APPLY_VISITOR_UNARY_HPP
14#define BOOST_VARIANT_DETAIL_APPLY_VISITOR_UNARY_HPP
15
16#include "boost/config.hpp"
17#include "boost/detail/workaround.hpp"
18#include "boost/variant/detail/generic_result_type.hpp"
19
20#include "boost/utility/enable_if.hpp"
21
22namespace boost {
23
24//////////////////////////////////////////////////////////////////////////
25// function template apply_visitor(visitor, visitable)
26//
27// Visits visitable with visitor.
28//
29
30//
31// nonconst-visitor version:
32//
33
34#if !BOOST_WORKAROUND(__EDG__, BOOST_TESTED_AT(302))
35
36#   define BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(V) \
37    BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename V::result_type) \
38    /**/
39
40#else // EDG-based compilers
41
42#   define BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(V) \
43    typename enable_if< \
44          mpl::not_< is_const< V > > \
45        , BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename V::result_type) \
46        >::type \
47    /**/
48
49#endif // EDG-based compilers workaround
50
51template <typename Visitor, typename Visitable>
52inline
53    BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(Visitor)
54apply_visitor(Visitor& visitor, Visitable& visitable)
55{
56    return visitable.apply_visitor(visitor);
57}
58
59#undef BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE
60
61//
62// const-visitor version:
63//
64
65#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
66
67template <typename Visitor, typename Visitable>
68inline
69    BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
70apply_visitor(const Visitor& visitor, Visitable& visitable)
71{
72    return visitable.apply_visitor(visitor);
73}
74
75#endif // MSVC7 and below exclusion
76
77} // namespace boost
78
79#endif // BOOST_VARIANT_DETAIL_APPLY_VISITOR_UNARY_HPP
Note: See TracBrowser for help on using the repository browser.