|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55309 - in sandbox/fmhess: boost/generic_ptr libs/generic_ptr/test
From: fmhess_at_[hidden]
Date: 2009-07-31 09:40:35
Author: fmhess
Date: 2009-07-31 09:40:34 EDT (Fri, 31 Jul 2009)
New Revision: 55309
URL: http://svn.boost.org/trac/boost/changeset/55309
Log:
Added some missing friend declarations needed for implicit
conversions from compatible pointer types.
Text files modified:
sandbox/fmhess/boost/generic_ptr/asserting.hpp | 7 +++++++
sandbox/fmhess/boost/generic_ptr/monitor.hpp | 6 ++++++
sandbox/fmhess/boost/generic_ptr/nonnull.hpp | 7 +++++++
sandbox/fmhess/boost/generic_ptr/throwing.hpp | 7 +++++++
sandbox/fmhess/libs/generic_ptr/test/basic_generic_pointer_test.cpp | 21 +++++++++++++++++++++
5 files changed, 48 insertions(+), 0 deletions(-)
Modified: sandbox/fmhess/boost/generic_ptr/asserting.hpp
==============================================================================
--- sandbox/fmhess/boost/generic_ptr/asserting.hpp (original)
+++ sandbox/fmhess/boost/generic_ptr/asserting.hpp 2009-07-31 09:40:34 EDT (Fri, 31 Jul 2009)
@@ -112,7 +112,14 @@
{
return px;
}
+
+// Tasteless as this may seem, making all members public allows member templates
+// to work in the absence of member template friends. (Matthew Langston)
+#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
private:
+ template<typename Y> friend class asserting;
+#endif
+
pointer px;
};
Modified: sandbox/fmhess/boost/generic_ptr/monitor.hpp
==============================================================================
--- sandbox/fmhess/boost/generic_ptr/monitor.hpp (original)
+++ sandbox/fmhess/boost/generic_ptr/monitor.hpp 2009-07-31 09:40:34 EDT (Fri, 31 Jul 2009)
@@ -127,7 +127,13 @@
return moveable_monitor_lock(*this);
}
+// Tasteless as this may seem, making all members public allows member templates
+// to work in the absence of member template friends. (Matthew Langston)
+#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
private:
+ template<typename Y, typename OtherMutex> friend class monitor;
+#endif
+
pointer px;
shared<mutex_type*> _mutex_p;
};
Modified: sandbox/fmhess/boost/generic_ptr/nonnull.hpp
==============================================================================
--- sandbox/fmhess/boost/generic_ptr/nonnull.hpp (original)
+++ sandbox/fmhess/boost/generic_ptr/nonnull.hpp 2009-07-31 09:40:34 EDT (Fri, 31 Jul 2009)
@@ -104,7 +104,14 @@
{
return px;
}
+
+// Tasteless as this may seem, making all members public allows member templates
+// to work in the absence of member template friends. (Matthew Langston)
+#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
private:
+ template<typename Y> friend class nonnull;
+#endif
+
pointer px;
};
Modified: sandbox/fmhess/boost/generic_ptr/throwing.hpp
==============================================================================
--- sandbox/fmhess/boost/generic_ptr/throwing.hpp (original)
+++ sandbox/fmhess/boost/generic_ptr/throwing.hpp 2009-07-31 09:40:34 EDT (Fri, 31 Jul 2009)
@@ -118,7 +118,14 @@
{
return px;
}
+
+// Tasteless as this may seem, making all members public allows member templates
+// to work in the absence of member template friends. (Matthew Langston)
+#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
private:
+ template<typename Y> friend class throwing;
+#endif
+
pointer px;
};
Modified: sandbox/fmhess/libs/generic_ptr/test/basic_generic_pointer_test.cpp
==============================================================================
--- sandbox/fmhess/libs/generic_ptr/test/basic_generic_pointer_test.cpp (original)
+++ sandbox/fmhess/libs/generic_ptr/test/basic_generic_pointer_test.cpp 2009-07-31 09:40:34 EDT (Fri, 31 Jul 2009)
@@ -87,6 +87,19 @@
>(xp_const);
}
+template<typename GenericPointer>
+void conversion_test(GenericPointer &p, bool is_cloning_pointer = false)
+{
+ // conversion to base pointer
+ typedef typename boost::generic_ptr::rebind<GenericPointer, Y>::other pointer_to_base_type;
+ pointer_to_base_type base_p(p);
+ BOOST_TEST(p == base_p ||
+ is_cloning_pointer);
+ base_p = p;
+ BOOST_TEST(p == base_p ||
+ is_cloning_pointer);
+}
+
int main()
{
{
@@ -94,6 +107,7 @@
X *p = &x;
rebind_test(p);
cast_test(p);
+ conversion_test(p);
}
{
X x;
@@ -102,6 +116,7 @@
dereference_test(p);
rebind_test(p);
cast_test(p);
+ conversion_test(p);
}
{
X x;
@@ -110,6 +125,7 @@
dereference_test(p);
rebind_test(p);
cast_test(p);
+ conversion_test(p);
}
{
X x;
@@ -118,6 +134,7 @@
dereference_test(p);
rebind_test(p);
cast_test(p);
+ conversion_test(p);
}
{
X x;
@@ -126,6 +143,7 @@
// dereference_test(p); // monitors don't support dereference
rebind_test(p);
cast_test(p);
+ conversion_test(p);
}
{
boost::generic_ptr::shared<X*> p(new X());
@@ -133,6 +151,7 @@
dereference_test(p);
rebind_test(p);
cast_test(p);
+ conversion_test(p);
}
{
X x;
@@ -141,6 +160,7 @@
dereference_test(p);
rebind_test(p);
cast_test(p);
+ conversion_test(p);
}
{
boost::generic_ptr::cloning<X*> p(new X());
@@ -148,6 +168,7 @@
dereference_test(p);
rebind_test(p);
cast_test(p);
+ conversion_test(p, true);
}
return 0;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk