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

ADL bug-fix

[SVN r22729]
This commit is contained in:
Joel de Guzman
2004-05-04 09:41:01 +00:00
parent 2ee25fda61
commit 8ae8430e7c

View File

@@ -13,20 +13,20 @@
# include <boost/python/tuple.hpp>
namespace boost { namespace python {
// Forward declaration
template <class Container, bool NoProxy, class DerivedPolicies>
class map_indexing_suite;
namespace detail
{
template <class Container, bool NoProxy>
class final_map_derived_policies
: public map_indexing_suite<Container,
class final_map_derived_policies
: public map_indexing_suite<Container,
NoProxy, final_map_derived_policies<Container, NoProxy> > {};
}
// The map_indexing_suite class is a predefined indexing_suite derived
// The map_indexing_suite class is a predefined indexing_suite derived
// class for wrapping std::vector (and std::vector like) classes. It provides
// all the policies required by the indexing_suite (see indexing_suite).
// Example usage:
@@ -43,11 +43,11 @@ namespace boost { namespace python {
// disabled by supplying *true* in the NoProxy template parameter.
//
template <
class Container,
class Container,
bool NoProxy = false,
class DerivedPolicies
class DerivedPolicies
= detail::final_map_derived_policies<Container, NoProxy> >
class map_indexing_suite
class map_indexing_suite
: public indexing_suite<
Container
, DerivedPolicies
@@ -57,9 +57,9 @@ namespace boost { namespace python {
, typename Container::key_type
, typename Container::key_type
>
{
{
public:
typedef typename Container::value_type value_type;
typedef typename Container::value_type::second_type data_type;
typedef typename Container::key_type key_type;
@@ -68,7 +68,7 @@ namespace boost { namespace python {
typedef typename Container::difference_type difference_type;
template <class Class>
static void
static void
extension_def(Class& cl)
{
// Wrap the map's element (value_type)
@@ -81,21 +81,21 @@ namespace boost { namespace python {
, return_internal_reference<>
, default_call_policies
>::type get_data_return_policy;
class_<value_type>(elem_name.c_str())
.def("__repr__", &DerivedPolicies::print_elem)
.def("data", &DerivedPolicies::get_data, get_data_return_policy())
.def("key", &DerivedPolicies::get_key)
;
}
static object
print_elem(typename Container::value_type const& e)
{
return "(%s, %s)" % make_tuple(e.first, e.second);
return "(%s, %s)" % python::make_tuple(e.first, e.second);
}
static
static
typename mpl::if_<
is_class<data_type>
, data_type&
@@ -112,9 +112,9 @@ namespace boost { namespace python {
return e.first;
}
static data_type&
static data_type&
get_item(Container& container, index_type i_)
{
{
typename Container::iterator i = container.find(i_);
if (i == container.end())
{
@@ -124,39 +124,39 @@ namespace boost { namespace python {
return i->second;
}
static void
static void
set_item(Container& container, index_type i, data_type const& v)
{
{
container[i] = v;
}
static void
static void
delete_item(Container& container, index_type i)
{
{
container.erase(i);
}
static size_t
size(Container& container)
{
return container.size();
}
static bool
contains(Container& container, key_type const& key)
{
return container.find(key) != container.end();
}
static bool
static bool
compare_index(Container& container, index_type a, index_type b)
{
return container.key_comp()(a, b);
}
static index_type
convert_index(Container& container, PyObject* i_)
{
{
extract<key_type const&> i(i_);
if (i.check())
{
@@ -174,7 +174,7 @@ namespace boost { namespace python {
return index_type();
}
};
}} // namespace boost::python
}} // namespace boost::python
#endif // MAP_INDEXING_SUITE_JDG20038_HPP