/* Copyright 2005 Alo Sarv * Distributed under the Boost Software Licence, Version 1.0 * (See accompanying file LICENCE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) */ #include #include #include // compile-time checks for detail::get_type template BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same::type> )); BOOST_MPL_ASSERT(( boost::is_same >::type> )); BOOST_MPL_ASSERT(( boost::is_same&>::type> )); BOOST_MPL_ASSERT(( boost::is_same*>::type> )); BOOST_MPL_ASSERT(( boost::is_same*&>::type> )); BOOST_MPL_ASSERT(( boost::is_same >::type> )); BOOST_MPL_ASSERT(( boost::is_same >::type> )); BOOST_MPL_ASSERT(( boost::is_same >::type> )); BOOST_MPL_ASSERT(( boost::is_same >::type> )); // calls const function on type template void process1(T t) { unchain_ptr(t).foo(); } // calls non-const function on type template void process2(T t) { unchain_ptr(t).bar(); } struct X { void foo() const { std::cerr << "foo()" << std::endl; } void bar() { std::cerr << "bar()" << std::endl; } }; struct nullDeleter { template void operator()(T t) {} }; int main() { X t1; process1(t1); process2(t1); X *t2 = new X; process1(t2); process2(t2); X **t3 = &t2; process1(t3); process2(t3); boost::shared_ptr t4(new X); process1(t4); process2(t4); boost::shared_ptr t5(new X); process1(t5); boost::shared_ptr t6(&t2, nullDeleter()); process1(t6); process2(t6); }