fix doc example typo
[boost.git] / boost / ptr_container / nullable.hpp
blobb3e4603d1ed9b1d00e16b8054922e949db674c25
1 //
2 // Boost.Pointer Container
3 //
4 // Copyright Thorsten Ottosen 2003-2005. Use, modification and
5 // distribution is subject to the Boost Software License, Version
6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // For more information, see http://www.boost.org/libs/ptr_container/
13 #ifndef BOOST_INDIRECT_CONTAINER_NULLABLE_HPP
14 #define BOOST_INDIRECT_CONTAINER_NULLABLE_HPP
16 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
17 # pragma once
18 #endif
20 #include <boost/type_traits/detail/yes_no_type.hpp>
21 #include <boost/mpl/eval_if.hpp>
22 #include <boost/mpl/identity.hpp>
23 #include <boost/config.hpp>
25 namespace boost
28 template< class T >
29 struct nullable
31 typedef T type;
32 };
34 namespace ptr_container_detail
36 template< class T >
37 type_traits::yes_type is_nullable( const nullable<T>* );
39 type_traits::no_type is_nullable( ... );
42 template< class T >
43 struct is_nullable
45 private:
46 BOOST_STATIC_CONSTANT( T*, var );
47 public:
49 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
50 #pragma warning(push)
51 #pragma warning(disable:6334)
52 #endif
54 BOOST_STATIC_CONSTANT(bool, value = sizeof( ptr_container_detail::is_nullable( var ) )
55 == sizeof( type_traits::yes_type ) );
56 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
57 #pragma warning(pop)
58 #endif
62 template< class T >
63 struct remove_nullable
65 typedef BOOST_DEDUCED_TYPENAME mpl::eval_if< is_nullable<T>,
67 mpl::identity<T> >::type
68 type;
73 #endif