2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-19 16:32:16 +00:00

Rationalize some identifier names

[SVN r21150]
This commit is contained in:
Raoul Gough
2003-12-05 17:36:14 +00:00
parent 183918be07
commit 494bede2c0
14 changed files with 156 additions and 143 deletions

View File

@@ -1,11 +1,14 @@
// Header file container_proxy.hpp
//
// Copyright (c) 2003 Raoul M. Gough
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
// at http://www.boost.org/LICENSE_1_0.txt)
//
// Header file container_proxy.hpp
//
// A container-wrapper that provides Python-style reference semantics
// for values stored in vector-like containers via element proxies.
//
// Class invariant:
// size() == m_proxies.size()
// for 0 <= i < size()
@@ -39,7 +42,6 @@
#include <boost/python/suite/indexing/container_traits.hpp>
#include <boost/python/suite/indexing/container_suite.hpp>
#include <boost/python/suite/indexing/algorithms.hpp>
#include <boost/python/suite/indexing/algo_selector.hpp>
namespace boost { namespace python { namespace indexing {
@@ -683,17 +685,18 @@ namespace boost { namespace python { namespace indexing {
#if defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
// value_traits for the reference type (i.e. our element_proxy
// instance) supplies a custom visitor_helper. Compilers without
// partial specialization need help here.
// instance) supplies a custom visit_container_class. Compilers
// without partial specialization need help here.
typedef element_proxy_traits<Container> value_traits_;
typedef element_proxy_traits<Container> value_traits_type;
// Hide base class visitor_helper, which would call the
// Hide base class visit_container_class, which would call the
// unspecialized value_traits version
template<typename PythonClass, typename Policy>
static void visitor_helper (PythonClass &pyClass, Policy const &policy)
static void visit_container_class(
PythonClass &pyClass, Policy const &policy)
{
value_traits_::visitor_helper (pyClass, policy);
value_traits_type::visit_container_class (pyClass, policy);
}
#endif
};
@@ -701,11 +704,11 @@ namespace boost { namespace python { namespace indexing {
#if !defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
namespace detail {
///////////////////////////////////////////////////////////////////////
// algo_selector support for container_proxy instances
// algorithms support for container_proxy instances
///////////////////////////////////////////////////////////////////////
template <typename RawContainer, typename Holder, typename Generator>
class selector_impl<container_proxy<RawContainer, Holder, Generator> >
class algorithms_selector<container_proxy<RawContainer, Holder, Generator> >
{
typedef container_proxy<RawContainer, Holder, Generator> Container;

View File

@@ -1,13 +1,13 @@
// -*- mode:c++ -*-
//
// Header file container_suite.hpp
//
// Copyright (c) 2003 Raoul M. Gough
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
// at http://www.boost.org/LICENSE_1_0.txt)
//
// Header file container_suite.hpp
//
// Top-level interface to the container suite.
//
// History
// =======
// 2003/ 8/23 rmg File creation
@@ -19,7 +19,7 @@
#ifndef BOOST_PYTHON_INDEXING_CONTAINER_SUITE_HPP
#define BOOST_PYTHON_INDEXING_CONTAINER_SUITE_HPP
#include <boost/python/suite/indexing/algo_selector.hpp>
#include <boost/python/suite/indexing/algorithms.hpp>
#include <boost/python/suite/indexing/visitor.hpp>
#include <boost/python/return_by_value.hpp>
@@ -33,7 +33,7 @@ namespace boost { namespace python { namespace indexing {
class Container,
int Flags = 0,
class Algorithms
= algo_selector<Container>
= algorithms<Container>
>
struct container_suite
: public visitor<Algorithms, default_container_policies, Flags>

View File

@@ -1,14 +1,14 @@
// Header file container_traits.hpp
//
// Traits information about entire containers for use in determining
// what Python methods to support for a container.
//
// Copyright (c) 2003 Raoul M. Gough
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
// at http://www.boost.org/LICENSE_1_0.txt)
//
// Header file container_traits.hpp
//
// Traits information about entire containers for use in determining
// what Python methods to provide.
//
// History
// =======
// 2003/ 8/23 rmg File creation as container_suite.hpp
@@ -85,26 +85,25 @@ namespace boost { namespace python { namespace indexing {
typedef typename make_signed<size_type>::type index_type;
// at(), operator[]. Signed to support Python -ve indexes
typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS <value_type>::param_type
typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS<value_type>::param_type
value_param;
typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS <key_type>::param_type
typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS<key_type>::param_type
key_param;
typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS <index_type>::param_type
typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS<index_type>::param_type
index_param;
// Allow client code to replace the default value traits via our
// second (optional) template parameter
typedef value_traits<typename base_type::value_type> default_value_traits;
typedef typename detail::maybe_override<
default_value_traits, ValueTraits>::type value_traits_;
default_value_traits, ValueTraits>::type value_traits_type;
BOOST_STATIC_CONSTANT(
bool, has_mutable_ref
= ICE_AND (base_type::has_mutable_ref, is_mutable));
BOOST_STATIC_CONSTANT(
bool, has_find = value_traits_::equality_comparable);
bool, has_find = value_traits_type::equality_comparable);
// Assume the worst for everything else
BOOST_STATIC_CONSTANT (bool, has_insert = false);
@@ -112,11 +111,12 @@ namespace boost { namespace python { namespace indexing {
BOOST_STATIC_CONSTANT (bool, has_pop_back = false);
BOOST_STATIC_CONSTANT (bool, has_push_back = false);
// Forward visitor_helper to value_traits_
// Forward visit_container_class to value_traits_type
template<typename PythonClass, typename Policy>
static void visitor_helper (PythonClass &pyClass, Policy const &policy)
static void visit_container_class(
PythonClass &pyClass, Policy const &policy)
{
value_traits_::visitor_helper (pyClass, policy);
value_traits_type::visit_container_class (pyClass, policy);
}
};

View File

@@ -1,11 +1,11 @@
// Header file deque.hpp
//
// Copyright (c) 2003 Raoul M. Gough
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
// at http://www.boost.org/LICENSE_1_0.txt)
//
// Header file deque.hpp
//
// Indexing algorithms support for std::deque instances
//
// History
@@ -21,18 +21,17 @@
#include <boost/python/suite/indexing/container_traits.hpp>
#include <boost/python/suite/indexing/container_suite.hpp>
#include <boost/python/suite/indexing/algorithms.hpp>
#include <boost/python/suite/indexing/algo_selector.hpp>
#include <deque>
namespace boost { namespace python { namespace indexing {
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
namespace detail {
///////////////////////////////////////////////////////////////////////
// algo_selector support for std::deque instances
// algorithms support for std::deque instances
///////////////////////////////////////////////////////////////////////
template <class T, class Allocator>
class selector_impl<std::deque<T, Allocator> >
class algorithms_selector<std::deque<T, Allocator> >
{
typedef std::deque<T, Allocator> Container;

View File

@@ -1,16 +1,18 @@
// Header file element_proxy_traits.hpp
//
// Copyright (c) 2003 Raoul M. Gough
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
// at http://www.boost.org/LICENSE_1_0.txt)
//
// Header file element_proxy_traits.hpp
//
// Note: element_proxy.hpp must be included before this header
//
// This is a separate header so that element_proxy.hpp is not
// dependant on register_ptr_to_python.hpp. This avoids a problem with
// two-phase name lookup, where register_ptr_to_python must be
// included *after* the element_proxy overload of boost::get_pointer
// is defined.
// is declared.
//
// History
// =======
@@ -33,26 +35,26 @@ namespace boost { namespace python { namespace indexing {
: public value_traits<
BOOST_DEDUCED_TYPENAME ContainerProxy::raw_value_type>
{
typedef element_proxy<ContainerProxy> element_proxy_;
typedef element_proxy<ContainerProxy> element_proxy_type;
typedef typename ContainerProxy::raw_value_type raw_value_type;
typedef value_traits<raw_value_type> base_type;
// Wrap the base class versions of the comparisons using
// indirection
struct less
: std::binary_function<element_proxy_, element_proxy_, bool>
: std::binary_function<element_proxy_type, element_proxy_type, bool>
{
typename base_type::less m_base_compare;
bool operator()(
element_proxy_ const &p1, element_proxy_ const &p2) const
element_proxy_type const &p1, element_proxy_type const &p2) const
{
return m_base_compare (*p1, *p2);
}
};
struct equal_to
: std::binary_function<raw_value_type, element_proxy_, bool>
: std::binary_function<raw_value_type, element_proxy_type, bool>
{
// First param is raw_value_type to interface smoothly with the
// bind1st used in default_algorithms::find
@@ -60,17 +62,17 @@ namespace boost { namespace python { namespace indexing {
typename base_type::equal_to m_base_compare;
bool operator()(
raw_value_type const &v, element_proxy_ const &p) const
raw_value_type const &v, element_proxy_type const &p) const
{
return m_base_compare (v, *p);
}
};
template<typename PythonClass, typename Policy>
static void visitor_helper (PythonClass &, Policy const &)
static void visit_container_class (PythonClass &, Policy const &)
{
boost::python::register_ptr_to_python<element_proxy_>();
boost::python::implicitly_convertible<raw_value_type, element_proxy_>();
register_ptr_to_python<element_proxy_type>();
implicitly_convertible<raw_value_type, element_proxy_type>();
}
};

View File

@@ -1,13 +1,11 @@
// -*- mode:c++ -*-
//
// Header file int_slice_helper.hpp
//
// Copyright (c) 2003 Raoul M. Gough
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
// at http://www.boost.org/LICENSE_1_0.txt)
//
// Header file int_slice_helper.hpp
//
// History
// =======
// 2003/10/13 rmg File creation
@@ -28,13 +26,13 @@ namespace boost { namespace python { namespace indexing {
// Works with a SliceType that provides an int-like index_type
// that is convertible to the algorithm's index_param
typedef Algorithms algorithms;
typedef Algorithms algorithms_type;
typedef SliceType slice_type;
typedef typename algorithms::container container;
typedef typename algorithms::reference reference;
typedef typename algorithms::value_param value_param;
typedef typename algorithms::container_traits container_traits;
typedef typename algorithms_type::container container;
typedef typename algorithms_type::reference reference;
typedef typename algorithms_type::value_param value_param;
typedef typename algorithms_type::container_traits container_traits;
typedef typename slice_type::index_type index_type;
int_slice_helper (container &c, slice_type const &);
@@ -91,7 +89,7 @@ namespace boost { namespace python { namespace indexing {
typename int_slice_helper<Algorithms, SliceType>::reference
int_slice_helper<Algorithms, SliceType>::current () const
{
return algorithms::get (*m_ptr, m_pos);
return algorithms_type::get (*m_ptr, m_pos);
}
template<typename Algorithms, typename SliceType>
@@ -111,7 +109,7 @@ namespace boost { namespace python { namespace indexing {
template<typename Algorithms, typename SliceType>
void int_slice_helper<Algorithms, SliceType>::assign (value_param val) const
{
algorithms::assign (*m_ptr, m_pos, val);
algorithms_type::assign (*m_ptr, m_pos, val);
}
namespace detail {

View File

@@ -1,14 +1,14 @@
// Header file iterator_range.hpp
//
// Emulate an STL container using a pair of iterators. Doesn't support
// insertion or deletion, for the obvious reasons.
//
// Copyright (c) 2003 Raoul M. Gough
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
// at http://www.boost.org/LICENSE_1_0.txt)
//
// Header file iterator_range.hpp
//
// Emulate an STL container using a pair of iterators. Doesn't support
// insertion or deletion, for the obvious reasons.
//
// History
// =======
// 2003/ 9/ 9 rmg File creation as iterator_pair.hpp
@@ -28,7 +28,6 @@
#include <boost/python/suite/indexing/container_traits.hpp>
#include <boost/python/suite/indexing/container_suite.hpp>
#include <boost/python/suite/indexing/algorithms.hpp>
#include <boost/python/suite/indexing/algo_selector.hpp>
namespace boost { namespace python { namespace indexing {
template<typename Iterator>
@@ -183,11 +182,11 @@ namespace boost { namespace python { namespace indexing {
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
namespace detail {
///////////////////////////////////////////////////////////////////////
// algo_selector support for iterator_range instances
// algorithms support for iterator_range instances
///////////////////////////////////////////////////////////////////////
template <typename Iterator>
class selector_impl<iterator_range<Iterator> >
class algorithms_selector<iterator_range<Iterator> >
{
typedef iterator_range<Iterator> Container;

View File

@@ -1,11 +1,11 @@
// Header file list.hpp
//
// Copyright (c) 2003 Raoul M. Gough
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
// at http://www.boost.org/LICENSE_1_0.txt)
//
// Header file list.hpp
//
// Indexing algorithms support for std::list instances
//
// History
@@ -21,7 +21,6 @@
#include <boost/python/suite/indexing/container_traits.hpp>
#include <boost/python/suite/indexing/container_suite.hpp>
#include <boost/python/suite/indexing/algorithms.hpp>
#include <boost/python/suite/indexing/algo_selector.hpp>
#include <list>
#if BOOST_WORKAROUND (BOOST_MSVC, == 1200)
@@ -58,11 +57,11 @@ namespace boost { namespace python { namespace indexing {
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
namespace detail {
///////////////////////////////////////////////////////////////////////
// algo_selector support for std::list instances
// algorithms support for std::list instances
///////////////////////////////////////////////////////////////////////
template <class T, class Allocator>
class selector_impl<std::list<T, Allocator> >
class algorithms_selector<std::list<T, Allocator> >
{
typedef std::list<T, Allocator> Container;
@@ -103,14 +102,17 @@ namespace boost { namespace python { namespace indexing {
template<typename ContainerTraits, typename Ovr>
void list_algorithms<ContainerTraits, Ovr>::sort (container &c)
{
typedef typename self_type::container_traits::value_traits_ value_traits_;
typedef typename value_traits_::less comparison;
typedef typename self_type::container_traits::value_traits_type
vtraits;
typedef typename vtraits::less comparison;
#if BOOST_WORKAROUND (BOOST_MSVC, == 1200)
// MSVC6 doesn't have a templated sort member in list, so we just
// use the parameterless version. This gives the correct behaviour
// provided that value_traits_::less is std::less<value_type>. It
// would be possible to support std::greater<T> (the only other
// overload of list::sort in MSVC6) with some additional work.
// provided that value_traits_type::less is exactly
// std::less<value_type>. It would be possible to support
// std::greater<T> (the only other overload of list::sort in
// MSVC6) with some additional work.
BOOST_STATIC_ASSERT(
(::boost::is_same<comparison, std::less<value_type> >::value));
c.sort ();

View File

@@ -1,11 +1,11 @@
// Header file map.hpp
//
// Copyright (c) 2003 Raoul M. Gough
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
// at http://www.boost.org/LICENSE_1_0.txt)
//
// Header file map.hpp
//
// Indexing algorithms support for std::map instances
//
// History
@@ -21,8 +21,6 @@
#include <boost/python/suite/indexing/container_traits.hpp>
#include <boost/python/suite/indexing/container_suite.hpp>
#include <boost/python/suite/indexing/algorithms.hpp>
#include <boost/python/suite/indexing/algo_selector.hpp>
#include <boost/python/suite/indexing/algo_selector.hpp>
#include <boost/detail/workaround.hpp>
#include <map>
@@ -91,11 +89,11 @@ namespace boost { namespace python { namespace indexing {
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
namespace detail {
///////////////////////////////////////////////////////////////////////
// algo_selector support for std::map instances
// algorithms support for std::map instances
///////////////////////////////////////////////////////////////////////
template <class Key, class T, class Compare, class Allocator>
class selector_impl<std::map<Key, T, Compare, Allocator> >
class algorithms_selector<std::map<Key, T, Compare, Allocator> >
{
typedef std::map<Key, T, Compare, Allocator> Container;
@@ -108,11 +106,11 @@ namespace boost { namespace python { namespace indexing {
};
///////////////////////////////////////////////////////////////////////
// algo_selector support for std::multimap instances
// algorithms support for std::multimap instances
///////////////////////////////////////////////////////////////////////
template <class Key, class T, class Compare, class Allocator>
class selector_impl<std::multimap<Key, T, Compare, Allocator> >
class algorithms_selector<std::multimap<Key, T, Compare, Allocator> >
{
typedef std::multimap<Key, T, Compare, Allocator> Container;

View File

@@ -48,7 +48,7 @@ namespace boost { namespace python { namespace indexing {
> base_type;
public:
typedef ContainerProxy container_proxy_;
typedef ContainerProxy container_proxy_type;
typedef Iter raw_iterator;
typedef Traits raw_iterator_traits;
@@ -59,9 +59,12 @@ namespace boost { namespace python { namespace indexing {
typedef value_type *pointer;
typedef value_type reference; // Already has reference semantics
proxy_iterator (container_proxy_ *p, size_type i) : ptr (p), index (i) { }
proxy_iterator (container_proxy_type *p, size_type i)
: ptr (p), index (i)
{
}
proxy_iterator (container_proxy_ *p, raw_iterator iter)
proxy_iterator (container_proxy_type *p, raw_iterator iter)
: ptr (p), index (iter - p->raw_container().begin())
{
}
@@ -139,7 +142,7 @@ namespace boost { namespace python { namespace indexing {
#else
private:
#endif
container_proxy_ *ptr;
container_proxy_type *ptr;
size_type index;
};
} } }

View File

@@ -1,11 +1,11 @@
// Header file set.hpp
//
// Copyright (c) 2003 Raoul M. Gough
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
// at http://www.boost.org/LICENSE_1_0.txt)
//
// Header file set.hpp
//
// Indexing algorithms support for std::set instances
//
// History
@@ -21,7 +21,6 @@
#include <boost/python/suite/indexing/container_traits.hpp>
#include <boost/python/suite/indexing/container_suite.hpp>
#include <boost/python/suite/indexing/algorithms.hpp>
#include <boost/python/suite/indexing/algo_selector.hpp>
#include <set>
namespace boost { namespace python { namespace indexing {
@@ -79,11 +78,11 @@ namespace boost { namespace python { namespace indexing {
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
namespace detail {
///////////////////////////////////////////////////////////////////////
// algo_selector support for std::set instances
// algorithms support for std::set instances
///////////////////////////////////////////////////////////////////////
template <class Key, class Compare, class Allocator>
class selector_impl<std::set<Key, Compare, Allocator> >
class algorithms_selector<std::set<Key, Compare, Allocator> >
{
typedef std::set<Key, Compare, Allocator> Container;
@@ -96,11 +95,11 @@ namespace boost { namespace python { namespace indexing {
};
///////////////////////////////////////////////////////////////////////
// algo_selector support for std::multiset instances
// algorithms support for std::multiset instances
///////////////////////////////////////////////////////////////////////
template <class Key, class Compare, class Allocator>
class selector_impl<std::multiset<Key, Compare, Allocator> >
class algorithms_selector<std::multiset<Key, Compare, Allocator> >
{
typedef std::multiset<Key, Compare, Allocator> Container;

View File

@@ -1,16 +1,14 @@
// -*- mode:c++ -*-
//
// Header file value_traits.hpp
//
// Traits information about container element types for use in
// determining which Python methods to support for a container.
//
// Copyright (c) 2003 Raoul M. Gough
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
// at http://www.boost.org/LICENSE_1_0.txt)
//
// Header file value_traits.hpp:
//
// Traits information for use in determining which Python methods to
// support for a container with elements of a given type.
//
// History
// =======
// 2003/ 9/12 rmg File creation
@@ -26,29 +24,31 @@
#include <functional>
namespace boost { namespace python { namespace indexing {
// The value_traits template is used by default by all
// ContainerTraits templates. It can be overridden by specialization
// or by supplying the optional ValueTraits parameter to a container
// traits template.
// The default_value_traits template is used by all ContainerTraits
// templates. It can be overridden by specialization or by supplying
// the optional ValueTraits parameter to a container traits
// template.
template<typename T> struct value_traits;
// Implementation for default use
// Implementation for default use. Providing this in a separate
// template allows specializations of value_traits to make use of
// it.
template<typename T>
struct default_value_traits {
struct simple_value_traits {
BOOST_STATIC_CONSTANT (bool, equality_comparable = true);
typedef std::equal_to<T> equal_to;
BOOST_STATIC_CONSTANT (bool, lessthan_comparable = true);
BOOST_STATIC_CONSTANT (bool, less_than_comparable = true);
typedef std::less<T> less;
// Default, do-nothing, version of visitor_helper
// Default, do-nothing, version of visit_container_class
template<typename PythonClass, typename Policy>
static void visitor_helper (PythonClass &, Policy const &) { }
static void visit_container_class (PythonClass &, Policy const &) { }
};
// Implementation using pointer indirection
template <typename Ptr>
struct indirect_value_traits : default_value_traits<Ptr> {
struct indirect_value_traits : simple_value_traits<Ptr> {
// Hide the base class versions of the comparisons, using these
// indirect versions
struct less : std::binary_function<Ptr, Ptr, bool> {
@@ -64,10 +64,10 @@ namespace boost { namespace python { namespace indexing {
};
};
// Default implementation selection
// Default implementation selection. It's basically just a typedef
// for simple_value_traits
template<typename T>
struct value_traits
: default_value_traits<T>
struct value_traits : simple_value_traits<T>
{
};

View File

@@ -1,11 +1,11 @@
// Header file vector.hpp
//
// Copyright (c) 2003 Raoul M. Gough
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
// at http://www.boost.org/LICENSE_1_0.txt)
//
// Header file vector.hpp
//
// Indexing algorithms support for std::vector instances
//
// History
@@ -21,18 +21,17 @@
#include <boost/python/suite/indexing/container_traits.hpp>
#include <boost/python/suite/indexing/container_suite.hpp>
#include <boost/python/suite/indexing/algorithms.hpp>
#include <boost/python/suite/indexing/algo_selector.hpp>
#include <vector>
namespace boost { namespace python { namespace indexing {
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
namespace detail {
///////////////////////////////////////////////////////////////////////
// algo_selector support for std::vector instances
// algorithms support for std::vector instances
///////////////////////////////////////////////////////////////////////
template <class T, class Allocator>
class selector_impl<std::vector<T, Allocator> >
class algorithms_selector<std::vector<T, Allocator> >
{
typedef std::vector<T, Allocator> Container;

View File

@@ -1,11 +1,14 @@
// Header file visitor.hpp
//
// Copyright (c) 2003 Raoul M. Gough
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
// at http://www.boost.org/LICENSE_1_0.txt)
//
// Header file visitor.hpp:
//
// def_visitor implementation to install the container_suite's Python
// methods in an object of a boost::python::class_<> instance.
//
// History
// =======
// 2003/ 9/11 rmg File creation from container_suite.hpp
@@ -26,9 +29,16 @@
#include <boost/bind.hpp>
#include <functional>
#define ICE_AND(a, b) ::boost::type_traits::ice_and <(a), (b)>::value
#define ICE_NOT(a) ::boost::type_traits::ice_not <(a)>::value
// undef'd at end of header
# if defined (BOOST_MSVC)
// Prevent MSVC int-to-bool truncation warning (C4305)
# define QUIET_BOOL(val) static_cast<bool>(val)
# else
# define QUIET_BOOL(val) (val)
# endif
# define ICE_AND(a, b) ::boost::type_traits::ice_and <(a), (b)>::value
# define ICE_NOT(a) ::boost::type_traits::ice_not <QUIET_BOOL(a)>::value
// these three macros undef'd at end of header
namespace boost { namespace python { namespace indexing {
enum visitor_flags {
@@ -495,9 +505,9 @@ namespace boost { namespace python { namespace indexing {
Policy m_policy;
public:
typedef Algorithms algorithms;
typedef typename algorithms::container_traits traits;
typedef typename traits::value_traits_ value_traits_;
typedef Algorithms algorithms_type;
typedef typename algorithms_type::container_traits traits;
typedef typename traits::value_traits_type value_traits_type;
explicit visitor (Policy const &policy = Policy()) : m_policy (policy) { }
@@ -523,43 +533,43 @@ namespace boost { namespace python { namespace indexing {
ICE_AND(
traits::has_copyable_iter,
ICE_NOT (Flags & disable_len))
>::apply (pyClass, algorithms(), precallPolicy);
>::apply (pyClass, algorithms_type(), precallPolicy);
maybe_add_getitem <has_indexing, has_slicing>
::apply (pyClass, algorithms(), m_policy);
::apply (pyClass, algorithms_type(), m_policy);
maybe_add_setitem<
ICE_AND (traits::has_mutable_ref, has_indexing),
has_slicing
>::apply (pyClass, algorithms(), m_policy);
>::apply (pyClass, algorithms_type(), m_policy);
maybe_add_delitem<ICE_AND (traits::has_erase, has_indexing), has_slicing>
::apply (pyClass, algorithms(), m_policy);
::apply (pyClass, algorithms_type(), m_policy);
maybe_add_iter<
ICE_AND(
traits::index_style != index_style_linear,
traits::has_copyable_iter)
>::apply (pyClass, algorithms(), m_policy);
>::apply (pyClass, algorithms_type(), m_policy);
maybe_add_sort<
ICE_AND(
ICE_AND(
traits::is_reorderable,
value_traits_::lessthan_comparable),
value_traits_type::less_than_comparable),
ICE_NOT (Flags & disable_reorder))
>::apply (pyClass, algorithms(), precallPolicy);
>::apply (pyClass, algorithms_type(), precallPolicy);
maybe_add_reverse<
ICE_AND (traits::is_reorderable, ICE_NOT (Flags & disable_reorder))
>::apply (pyClass, algorithms(), precallPolicy);
>::apply (pyClass, algorithms_type(), precallPolicy);
maybe_add_append<traits::has_push_back>
::apply (pyClass, algorithms(), precallPolicy);
::apply (pyClass, algorithms_type(), precallPolicy);
maybe_add_insert<
ICE_AND (traits::has_insert, ICE_NOT (Flags & disable_insert))
>::apply (pyClass, algorithms(), precallPolicy);
>::apply (pyClass, algorithms_type(), precallPolicy);
maybe_add_extend<
ICE_AND(
@@ -567,7 +577,7 @@ namespace boost { namespace python { namespace indexing {
traits::index_style == index_style_linear,
traits::has_insert),
ICE_NOT (Flags & disable_extend))
>::apply (pyClass, algorithms(), precallPolicy);
>::apply (pyClass, algorithms_type(), precallPolicy);
maybe_add_index<
ICE_AND(
@@ -575,21 +585,22 @@ namespace boost { namespace python { namespace indexing {
traits::index_style == index_style_linear,
traits::has_find),
ICE_NOT (Flags & disable_search))
>::apply (pyClass, algorithms(), precallPolicy);
>::apply (pyClass, algorithms_type(), precallPolicy);
maybe_add_count<
ICE_AND(
traits::has_find,
ICE_NOT (Flags & disable_search)),
traits::index_style
>::apply (pyClass, algorithms(), precallPolicy);
>::apply (pyClass, algorithms_type(), precallPolicy);
Algorithms::visitor_helper (pyClass, m_policy);
Algorithms::visit_container_class (pyClass, m_policy);
}
};
} } }
#undef ICE_AND
#undef ICE_NOT
#undef ICE_AND
#undef QUIET_BOOL
#endif // BOOST_PYTHON_INDEXING_VISITOR_HPP