|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55310 - in sandbox/fmhess: boost/generic_ptr libs/generic_ptr/test
From: fmhess_at_[hidden]
Date: 2009-07-31 09:57:43
Author: fmhess
Date: 2009-07-31 09:57:43 EDT (Fri, 31 Jul 2009)
New Revision: 55310
URL: http://svn.boost.org/trac/boost/changeset/55310
Log:
Fixed conversions to const void generic pointer.
Text files modified:
sandbox/fmhess/boost/generic_ptr/pointer_traits.hpp | 10 ++++---
sandbox/fmhess/libs/generic_ptr/test/basic_generic_pointer_test.cpp | 53 ++++++++++++++++++++++++++++++++-------
2 files changed, 49 insertions(+), 14 deletions(-)
Modified: sandbox/fmhess/boost/generic_ptr/pointer_traits.hpp
==============================================================================
--- sandbox/fmhess/boost/generic_ptr/pointer_traits.hpp (original)
+++ sandbox/fmhess/boost/generic_ptr/pointer_traits.hpp 2009-07-31 09:57:43 EDT (Fri, 31 Jul 2009)
@@ -72,24 +72,26 @@
typedef void * pointer;
typedef void reference;
};
- template<> struct pointer_traits<const void*>
+#if !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS)
+ template<> struct pointer_traits<const void*>
{
- typedef void value_type;
+ typedef const void value_type;
typedef const void * pointer;
typedef void reference;
};
template<> struct pointer_traits<volatile void*>
{
- typedef void value_type;
+ typedef volatile void value_type;
typedef volatile void * pointer;
typedef void reference;
};
template<> struct pointer_traits<const volatile void*>
{
- typedef void value_type;
+ typedef const volatile void value_type;
typedef const volatile void * pointer;
typedef void reference;
};
+#endif
template<typename T>
T * get_plain_old_pointer(T * p)
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:57:43 EDT (Fri, 31 Jul 2009)
@@ -88,9 +88,8 @@
}
template<typename GenericPointer>
-void conversion_test(GenericPointer &p, bool is_cloning_pointer = false)
+void conversion_to_base_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 ||
@@ -100,6 +99,32 @@
is_cloning_pointer);
}
+template<typename GenericPointer>
+void conversion_to_void_test(GenericPointer &p, bool is_cloning_pointer = false)
+{
+ typedef typename boost::generic_ptr::rebind<GenericPointer, void>::other pointer_to_void_type;
+ pointer_to_void_type void_p(p);
+ BOOST_TEST(p == void_p ||
+ is_cloning_pointer);
+ void_p = p;
+ BOOST_TEST(p == void_p ||
+ is_cloning_pointer);
+
+ typedef typename boost::generic_ptr::rebind
+ <
+ GenericPointer,
+ const typename boost::generic_ptr::pointer_traits<GenericPointer>::value_type
+ >::other pointer_to_const_type;
+ pointer_to_const_type cp(p);
+
+ typedef typename boost::generic_ptr::rebind
+ <
+ GenericPointer,
+ const void
+ >::other pointer_to_const_void_type;
+ pointer_to_const_void_type const_void_p(cp);
+}
+
int main()
{
{
@@ -107,7 +132,8 @@
X *p = &x;
rebind_test(p);
cast_test(p);
- conversion_test(p);
+ conversion_to_base_test(p);
+ conversion_to_void_test(p);
}
{
X x;
@@ -116,7 +142,8 @@
dereference_test(p);
rebind_test(p);
cast_test(p);
- conversion_test(p);
+ conversion_to_base_test(p);
+ conversion_to_void_test(p);
}
{
X x;
@@ -125,7 +152,8 @@
dereference_test(p);
rebind_test(p);
cast_test(p);
- conversion_test(p);
+ conversion_to_base_test(p);
+ conversion_to_void_test(p);
}
{
X x;
@@ -134,7 +162,8 @@
dereference_test(p);
rebind_test(p);
cast_test(p);
- conversion_test(p);
+ conversion_to_base_test(p);
+ conversion_to_void_test(p);
}
{
X x;
@@ -143,7 +172,8 @@
// dereference_test(p); // monitors don't support dereference
rebind_test(p);
cast_test(p);
- conversion_test(p);
+ conversion_to_base_test(p);
+ conversion_to_void_test(p);
}
{
boost::generic_ptr::shared<X*> p(new X());
@@ -151,7 +181,8 @@
dereference_test(p);
rebind_test(p);
cast_test(p);
- conversion_test(p);
+ conversion_to_base_test(p);
+ conversion_to_void_test(p);
}
{
X x;
@@ -160,7 +191,8 @@
dereference_test(p);
rebind_test(p);
cast_test(p);
- conversion_test(p);
+ conversion_to_base_test(p);
+ // conversion_to_void_test(p); // intrusive doesn't support void pointers
}
{
boost::generic_ptr::cloning<X*> p(new X());
@@ -168,7 +200,8 @@
dereference_test(p);
rebind_test(p);
cast_test(p);
- conversion_test(p, true);
+ conversion_to_base_test(p);
+ conversion_to_void_test(p);
}
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