source: NonGTP/Boost/boost/python/return_internal_reference.hpp @ 857

Revision 857, 1.3 KB checked in by igarcia, 18 years ago (diff)
Line 
1// Copyright David Abrahams 2002.
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 RETURN_INTERNAL_REFERENCE_DWA2002131_HPP
6# define RETURN_INTERNAL_REFERENCE_DWA2002131_HPP
7
8# include <boost/python/detail/prefix.hpp>
9
10# include <boost/python/default_call_policies.hpp>
11# include <boost/python/reference_existing_object.hpp>
12# include <boost/python/with_custodian_and_ward.hpp>
13# include <boost/mpl/if.hpp>
14
15namespace boost { namespace python {
16
17namespace detail
18{
19  template <std::size_t>
20  struct return_internal_reference_owner_arg_must_be_greater_than_zero
21# if defined(__GNUC__) && __GNUC__ >= 3 || defined(__EDG__)
22  {}
23# endif
24  ;
25}
26
27template <std::size_t owner_arg = 1, class BasePolicy_ = default_call_policies>
28struct return_internal_reference
29    : with_custodian_and_ward_postcall<0, owner_arg, BasePolicy_>
30{
31 private:
32    BOOST_STATIC_CONSTANT(bool, legal = owner_arg > 0);
33 public:
34    typedef typename mpl::if_c<
35        legal
36        , reference_existing_object
37        , detail::return_internal_reference_owner_arg_must_be_greater_than_zero<owner_arg>
38    >::type result_converter;
39};
40
41}} // namespace boost::python
42
43#endif // RETURN_INTERNAL_REFERENCE_DWA2002131_HPP
Note: See TracBrowser for help on using the repository browser.