1 // Copyright David Abrahams 2003.
2 // Distributed under the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 #ifndef DEF_VISITOR_DWA2003810_HPP
6 # define DEF_VISITOR_DWA2003810_HPP
8 # include <boost/python/detail/prefix.hpp>
9 # include <boost/detail/workaround.hpp>
11 namespace boost { namespace python {
13 template <class DerivedVisitor> class def_visitor;
14 template <class T, class X1, class X2, class X3> class class_;
16 class def_visitor_access
18 # if defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) \
19 || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
20 // Tasteless as this may seem, making all members public allows member templates
21 // to work in the absence of member template friends.
24 template <class Derived> friend class def_visitor;
27 // unnamed visit, c.f. init<...>, container suites
28 template <class V, class classT>
29 static void visit(V const& v, classT& c)
31 v.derived_visitor().visit(c);
34 // named visit, c.f. object, pure_virtual
35 template <class V, class classT, class OptionalArgs>
40 , OptionalArgs const& options
43 v.derived_visitor().visit(c, name, options);
49 template <class DerivedVisitor>
52 friend class def_visitor_access;
54 # if defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) \
55 || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
56 // Tasteless as this may seem, making all members public allows member templates
57 // to work in the absence of member template friends.
60 template <class T, class X1, class X2, class X3> friend class class_;
63 // unnamed visit, c.f. init<...>, container suites
64 template <class classT>
65 void visit(classT& c) const
67 def_visitor_access::visit(*this, c);
70 // named visit, c.f. object, pure_virtual
71 template <class classT, class OptionalArgs>
72 void visit(classT& c, char const* name, OptionalArgs const& options) const
74 def_visitor_access::visit(*this, c, name, options);
78 DerivedVisitor const& derived_visitor() const
80 return static_cast<DerivedVisitor const&>(*this);
84 }} // namespace boost::python
86 #endif // DEF_VISITOR_DWA2003810_HPP