Skip to content

Commit 09e24cb

Browse files
committed
map bug fix when data type is a shared_ptr and NoProxy is true
[SVN r31787]
1 parent ac32d13 commit 09e24cb

3 files changed

Lines changed: 11 additions & 36 deletions

File tree

include/boost/python/suite/indexing/map_indexing_suite.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ namespace boost { namespace python {
7878
elem_name += "_entry";
7979

8080
typedef typename mpl::if_<
81-
is_class<data_type>
81+
mpl::and_<is_class<data_type>, mpl::bool_<!NoProxy> >
8282
, return_internal_reference<>
8383
, default_call_policies
8484
>::type get_data_return_policy;
@@ -98,7 +98,7 @@ namespace boost { namespace python {
9898

9999
static
100100
typename mpl::if_<
101-
is_class<data_type>
101+
mpl::and_<is_class<data_type>, mpl::bool_<!NoProxy> >
102102
, data_type&
103103
, data_type
104104
>::type

test/map_indexing_suite.cpp

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,6 @@ std::string x_value(X const& x)
2626
return "gotya " + x.s;
2727
}
2828

29-
30-
31-
struct domain
32-
{};
33-
34-
struct graph
35-
{
36-
typedef std::map <int, boost::shared_ptr <domain> > domains_t;
37-
domains_t domains_;
38-
};
39-
40-
41-
// objects::class_value_wrapper <boost::shared_ptr<domain>,
42-
// objects::make_ptr_instance <domain,
43-
// objects::pointer_holder <boost::shared_ptr<domain>, domain> > > ();
44-
45-
46-
47-
48-
4929
BOOST_PYTHON_MODULE(map_indexing_suite_ext)
5030
{
5131
class_<X>("X")
@@ -74,20 +54,10 @@ BOOST_PYTHON_MODULE(map_indexing_suite_ext)
7454
;
7555
#endif
7656

77-
// Compile check only...
57+
// Some more..
7858
class_<std::map<std::string, boost::shared_ptr<X> > >("TestMap")
79-
.def(map_indexing_suite<std::map<std::string, boost::shared_ptr<X> > >())
59+
.def(map_indexing_suite<std::map<std::string, boost::shared_ptr<X> >, true>())
8060
;
81-
82-
// Some more...
83-
class_<domain, boost::shared_ptr <domain> > ("domain");
84-
85-
class_<graph::domains_t> ("domains_map")
86-
.def (map_indexing_suite<graph::domains_t, true> ());
87-
88-
class_<graph> ("graph")
89-
.def_readonly ("domains", &graph::domains_);
90-
9161
}
9262

9363
#include "module_tail.cpp"

test/map_indexing_suite.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,15 @@
191191
# Some more...
192192
#####################################################################
193193
194-
>>> g = graph()
195-
>>> for el in g.domains:
194+
>>> tm = TestMap()
195+
>>> tm["joel"] = X("aaa")
196+
>>> tm["kimpo"] = X("bbb")
197+
>>> print_xmap(tm)
198+
[ (joel, aaa) (kimpo, bbb) ]
199+
>>> for el in tm:
196200
... print el.key(),
197201
... dom = el.data()
202+
joel kimpo
198203
199204
#####################################################################
200205
# END....

0 commit comments

Comments
 (0)