mirror of
https://github.com/boostorg/python.git
synced 2026-01-30 20:12:37 +00:00
Fix namespace naming issues
[SVN r20351]
This commit is contained in:
@@ -171,7 +171,7 @@
|
||||
|
||||
<pre>
|
||||
class_< std::vector<int> > ("vector_int")
|
||||
.def (our_namespace::container_suite< std::vector<int> >());
|
||||
.def (indexing::container_suite< std::vector<int> >());
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -211,7 +211,7 @@
|
||||
#include "algo_selector.hpp"
|
||||
#include "visitor.hpp"
|
||||
|
||||
namespace our_namespace {
|
||||
namespace boost { namespace python { namespace indexing {
|
||||
typedef return_value_policy<return_by_value> default_container_policies;
|
||||
|
||||
template<class Container, class Algorithms = algo_selector<Container> >
|
||||
@@ -221,7 +221,7 @@ namespace our_namespace {
|
||||
template<typename Policy>
|
||||
static visitor<Algorithms, Policy> with_policies (Policy const &policy);
|
||||
};
|
||||
}
|
||||
} } }
|
||||
</pre>
|
||||
</p>
|
||||
|
||||
@@ -232,14 +232,14 @@ namespace our_namespace {
|
||||
<ol>
|
||||
<li>
|
||||
|
||||
It relies on the <code>our_namespace::algo_selector</code>
|
||||
It relies on the <code>indexing::algo_selector</code>
|
||||
template, which uses partial template specialization, to
|
||||
select what functionality to provide for the container.
|
||||
|
||||
</li>
|
||||
<li>
|
||||
|
||||
It derives from the <code>our_namespace::visitor</code>
|
||||
It derives from the <code>indexing::visitor</code>
|
||||
template, using a <code>return_by_value</code> return
|
||||
policy. This is a reasonable default, and follows the
|
||||
Boost.Python idiom of passing a default-constructed object
|
||||
@@ -250,7 +250,7 @@ namespace our_namespace {
|
||||
|
||||
The <code>with_policies</code> static function template
|
||||
generates different instances of the
|
||||
<code>our_namespace::visitor</code> template, with
|
||||
<code>indexing::visitor</code> template, with
|
||||
client-provided policies.
|
||||
|
||||
</li>
|
||||
@@ -266,7 +266,7 @@ namespace our_namespace {
|
||||
|
||||
<pre>
|
||||
class_< std::list<heavy_class> > ("list_heavy_class")
|
||||
.def (our_namespace::container_suite< std::list<heavy_class> >
|
||||
.def (indexing::container_suite< std::list<heavy_class> >
|
||||
::with_policies (my_policies));
|
||||
</pre>
|
||||
|
||||
@@ -467,7 +467,7 @@ static void visitor_helper (PythonClass &, Policy const &);
|
||||
In order to include a custom <code>ValueTraits</code> class into
|
||||
the container suite, it is easiest to supply it as a
|
||||
specialization of the template
|
||||
<code>our_namespace::value_traits</code> for the container's
|
||||
<code>indexing::value_traits</code> for the container's
|
||||
element type. The existing <code>ContainerTraits</code> classes
|
||||
all make use of
|
||||
<code>value_traits<container::value_type></code>, and so
|
||||
@@ -484,21 +484,21 @@ static void visitor_helper (PythonClass &, Policy const &);
|
||||
errors caused by an attempt to provide the Python
|
||||
<code>find</code> or <code>sort</code> methods. The solution is
|
||||
to write a specialized version of
|
||||
<code>our_namespace::value_traits</code> that disables the
|
||||
<code>indexing::value_traits</code> that disables the
|
||||
appropriate features. For example:
|
||||
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
namespace our_namespace {
|
||||
namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct value_traits<my_type> : public value_traits<int>
|
||||
{
|
||||
static bool const equality_comparable = false;
|
||||
static bool const lessthan_comparable = false;
|
||||
};
|
||||
}
|
||||
} } }
|
||||
</pre>
|
||||
</p>
|
||||
|
||||
@@ -516,7 +516,7 @@ namespace our_namespace {
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
namespace our_namespace {
|
||||
namespace boost { namespace python { namespace indexing {
|
||||
template<typename T>
|
||||
struct value_traits {
|
||||
static bool const equality_comparable = true;
|
||||
@@ -526,7 +526,7 @@ namespace our_namespace {
|
||||
static void visitor_helper (PythonClass &, Policy const &)
|
||||
{ }
|
||||
};
|
||||
}
|
||||
} } }
|
||||
</pre>
|
||||
</p>
|
||||
|
||||
@@ -994,13 +994,13 @@ static void visitor_helper (PythonClass &, Policy const &);
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
namespace our_namespace {
|
||||
namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct algo_selector<my_container>
|
||||
: public default_algorithms<my_container_traits>
|
||||
{
|
||||
};
|
||||
}
|
||||
} } }
|
||||
</pre>
|
||||
</p>
|
||||
<p>
|
||||
@@ -1159,7 +1159,7 @@ BOOST_PYTHON_MODULE(test_simple) {
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
namespace our_namespace {
|
||||
namespace boost { namespace python { namespace indexing {
|
||||
template<typename ContainerTraits>
|
||||
struct default_algorithms
|
||||
{
|
||||
@@ -1191,7 +1191,7 @@ namespace our_namespace {
|
||||
template<typename PythonClass, typename Policy>
|
||||
static void visitor_helper (PythonClass &, Policy const &);
|
||||
};
|
||||
}
|
||||
} } }
|
||||
</pre>
|
||||
</p>
|
||||
|
||||
@@ -1199,7 +1199,7 @@ namespace our_namespace {
|
||||
|
||||
<p>
|
||||
|
||||
The existing <code>our_namespace::algo_selector</code> template
|
||||
The existing <code>indexing::algo_selector</code> template
|
||||
uses partial specializations and public derivation to select an
|
||||
<code>Algorithms</code> implementation suitable for any of the
|
||||
standard container types. Exactly how it does this should be
|
||||
@@ -1401,74 +1401,78 @@ namespace our_namespace {
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
template<class Container
|
||||
, class Holder = identity<Container> >
|
||||
class container_proxy
|
||||
{
|
||||
public:
|
||||
typedef typename Container::size_type size_type;
|
||||
typedef typename Container::difference_type difference_type;
|
||||
typedef typename Container::value_type raw_value_type;
|
||||
namespace boost { namespace python { namespace indexing {
|
||||
template<class Container
|
||||
, class Holder = identity<Container> >
|
||||
class container_proxy
|
||||
{
|
||||
public:
|
||||
typedef typename Container::size_type size_type;
|
||||
typedef typename Container::difference_type difference_type;
|
||||
typedef typename Container::value_type raw_value_type;
|
||||
|
||||
typedef typename Holder::held_type held_type;
|
||||
typedef typename Holder::held_type held_type;
|
||||
|
||||
typedef <i>implementation defined</i> value_type;
|
||||
typedef <i>implementation defined</i> const_value_type;
|
||||
typedef <i>implementation defined</i> value_type;
|
||||
typedef <i>implementation defined</i> const_value_type;
|
||||
|
||||
typedef value_type reference; // Has reference semantics
|
||||
typedef const_value_type const_reference; // Has reference semantics
|
||||
typedef value_type reference; // Has reference semantics
|
||||
typedef const_value_type const_reference; // Has reference semantics
|
||||
|
||||
struct iterator { <i>implementation defined</i> }
|
||||
struct iterator { <i>implementation defined</i> }
|
||||
|
||||
container_proxy ();
|
||||
explicit container_proxy (held_type const &);
|
||||
template<typename Iter> container_proxy (Iter, Iter);
|
||||
container_proxy ();
|
||||
explicit container_proxy (held_type const &);
|
||||
template<typename Iter> container_proxy (Iter, Iter);
|
||||
|
||||
container_proxy (container_proxy const &);
|
||||
container_proxy &operator= (container_proxy const &);
|
||||
~container_proxy ();
|
||||
container_proxy (container_proxy const &);
|
||||
container_proxy &operator= (container_proxy const &);
|
||||
~container_proxy ();
|
||||
|
||||
Container const &raw_container() const; // OK to expose const reference
|
||||
Container const &raw_container() const; // OK to expose const reference
|
||||
|
||||
reference at (size_type);
|
||||
const_reference at (size_type) const;
|
||||
reference at (size_type);
|
||||
const_reference at (size_type) const;
|
||||
|
||||
reference operator[] (size_type);
|
||||
const_reference operator[] (size_type) const;
|
||||
reference operator[] (size_type);
|
||||
const_reference operator[] (size_type) const;
|
||||
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type);
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type);
|
||||
|
||||
iterator begin();
|
||||
iterator end();
|
||||
iterator begin();
|
||||
iterator end();
|
||||
|
||||
iterator erase (iterator);
|
||||
iterator erase (iterator, iterator);
|
||||
iterator insert (iterator, raw_value_type const &);
|
||||
template<typename Iter> void insert (iterator, Iter, Iter);
|
||||
iterator erase (iterator);
|
||||
iterator erase (iterator, iterator);
|
||||
iterator insert (iterator, raw_value_type const &);
|
||||
template<typename Iter> void insert (iterator, Iter, Iter);
|
||||
|
||||
void push_back (raw_value_type const &);
|
||||
void push_back (raw_value_type const &);
|
||||
|
||||
value_type pop_back ();
|
||||
};
|
||||
value_type pop_back ();
|
||||
};
|
||||
} } }
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The <code>identity</code> template.
|
||||
|
||||
<pre>
|
||||
template<typename T> struct identity {
|
||||
typedef T held_type;
|
||||
namespace boost { namespace python { namespace indexing {
|
||||
template<typename T> struct identity {
|
||||
typedef T held_type;
|
||||
|
||||
static T & get(T & obj) { return obj; }
|
||||
static T const & get(T const & obj) { return obj; }
|
||||
static T & get(T & obj) { return obj; }
|
||||
static T const & get(T const & obj) { return obj; }
|
||||
|
||||
static T create () { return T(); }
|
||||
static T copy (T const &copy) { return copy; }
|
||||
static void assign (T &to, T const &from) { to = from; }
|
||||
static void pre_destruction (T &) { }
|
||||
};
|
||||
static T create () { return T(); }
|
||||
static T copy (T const &copy) { return copy; }
|
||||
static void assign (T &to, T const &from) { to = from; }
|
||||
static void pre_destruction (T &) { }
|
||||
};
|
||||
} } }
|
||||
</pre>
|
||||
</p>
|
||||
|
||||
@@ -1476,19 +1480,21 @@ template<typename T> struct identity {
|
||||
The <code>deref</code> template.
|
||||
|
||||
<pre>
|
||||
template<typename P> struct deref {
|
||||
typedef P held_type;
|
||||
namespace boost { namespace python { namespace indexing {
|
||||
template<typename P> struct deref {
|
||||
typedef P held_type;
|
||||
|
||||
typedef typename boost::iterator_value<P>::type value;
|
||||
typedef typename boost::iterator_value<P>::type value;
|
||||
|
||||
static value & get (P & ptr) { return *ptr; }
|
||||
static value const & get (P const & ptr) { return *ptr; }
|
||||
static value & get (P & ptr) { return *ptr; }
|
||||
static value const & get (P const & ptr) { return *ptr; }
|
||||
|
||||
static P create () { return P(); }
|
||||
static P copy (P const &copy) { return copy; }
|
||||
static void assign (P &to, P const &from) { to = from; }
|
||||
static void pre_destruction (P &) { }
|
||||
};
|
||||
static P create () { return P(); }
|
||||
static P copy (P const &copy) { return copy; }
|
||||
static void assign (P &to, P const &from) { to = from; }
|
||||
static void pre_destruction (P &) { }
|
||||
};
|
||||
} } }
|
||||
</pre>
|
||||
</p>
|
||||
|
||||
@@ -1651,7 +1657,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
directly, as in the following example:
|
||||
|
||||
<pre>
|
||||
using our_namespace;
|
||||
using namespace boost::python;
|
||||
using namespace boost::python::indexing;
|
||||
|
||||
class_<std::vector<int> > ("vector_int")
|
||||
.def (visitor <
|
||||
|
||||
Reference in New Issue
Block a user