diff --git a/test/pointer_traits_to_address_test.cpp b/test/pointer_traits_to_address_test.cpp index 3a86b42..aba0188 100644 --- a/test/pointer_traits_to_address_test.cpp +++ b/test/pointer_traits_to_address_test.cpp @@ -21,6 +21,44 @@ private: T value_; }; +template +class special { +public: + special(T* value) + : value_(value) { } + T* get() const BOOST_NOEXCEPT { + return value_; + } +private: + T* value_; +}; + +namespace boost { + +template +struct pointer_traits > { + typedef special pointer; + typedef T element_type; + typedef std::ptrdiff_t difference_type; + template + struct rebind_to { + typedef special type; + }; +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + template + using rebind = typename rebind_to::type; +#endif + template + static pointer pointer_to(U& v) BOOST_NOEXCEPT { + return pointer(&v); + } + static element_type* to_address(const pointer& v) BOOST_NOEXCEPT { + return v.get(); + } +}; + +} /* boost */ + int main() { int i = 0; @@ -59,5 +97,35 @@ int main() type p(&i); BOOST_TEST(boost::pointer_traits::to_address(p) == &i); } + { + typedef special type; + type p(&i); + BOOST_TEST(boost::pointer_traits::to_address(p) == &i); + } + { + typedef special type; + type p(&i); + BOOST_TEST(boost::pointer_traits::to_address(p) == &i); + } + { + typedef special type; + type p(&i); + BOOST_TEST(boost::pointer_traits::to_address(p) == &i); + } + { + typedef pointer > type; + type p(&i); + BOOST_TEST(boost::pointer_traits::to_address(p) == &i); + } + { + typedef pointer > type; + type p(&i); + BOOST_TEST(boost::pointer_traits::to_address(p) == &i); + } + { + typedef pointer > type; + type p(&i); + BOOST_TEST(boost::pointer_traits::to_address(p) == &i); + } return boost::report_errors(); }