Chris@16
|
1 //
|
Chris@16
|
2 // Boost.Pointer Container
|
Chris@16
|
3 //
|
Chris@16
|
4 // Copyright Thorsten Ottosen 2003-2005. Use, modification and
|
Chris@16
|
5 // distribution is subject to the Boost Software License, Version
|
Chris@16
|
6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8 //
|
Chris@16
|
9 // For more information, see http://www.boost.org/libs/ptr_container/
|
Chris@16
|
10 //
|
Chris@16
|
11
|
Chris@16
|
12
|
Chris@16
|
13 #ifndef BOOST_INDIRECT_CONTAINER_NULLABLE_HPP
|
Chris@16
|
14 #define BOOST_INDIRECT_CONTAINER_NULLABLE_HPP
|
Chris@16
|
15
|
Chris@16
|
16 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
17 # pragma once
|
Chris@16
|
18 #endif
|
Chris@16
|
19
|
Chris@16
|
20 #include <boost/type_traits/detail/yes_no_type.hpp>
|
Chris@16
|
21 #include <boost/mpl/eval_if.hpp>
|
Chris@16
|
22 #include <boost/mpl/identity.hpp>
|
Chris@16
|
23 #include <boost/config.hpp>
|
Chris@16
|
24
|
Chris@16
|
25 namespace boost
|
Chris@16
|
26 {
|
Chris@16
|
27
|
Chris@16
|
28 template< class T >
|
Chris@16
|
29 struct nullable
|
Chris@16
|
30 {
|
Chris@16
|
31 typedef T type;
|
Chris@16
|
32 };
|
Chris@16
|
33
|
Chris@16
|
34 namespace ptr_container_detail
|
Chris@16
|
35 {
|
Chris@16
|
36 template< class T >
|
Chris@16
|
37 type_traits::yes_type is_nullable( const nullable<T>* );
|
Chris@16
|
38
|
Chris@16
|
39 type_traits::no_type is_nullable( ... );
|
Chris@16
|
40 }
|
Chris@16
|
41
|
Chris@16
|
42 template< class T >
|
Chris@16
|
43 struct is_nullable
|
Chris@16
|
44 {
|
Chris@16
|
45 private:
|
Chris@16
|
46 BOOST_STATIC_CONSTANT( T*, var );
|
Chris@16
|
47 public:
|
Chris@16
|
48
|
Chris@16
|
49 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
Chris@16
|
50 #pragma warning(push)
|
Chris@16
|
51 #pragma warning(disable:6334)
|
Chris@16
|
52 #endif
|
Chris@16
|
53
|
Chris@16
|
54 BOOST_STATIC_CONSTANT(bool, value = sizeof( ptr_container_detail::is_nullable( var ) )
|
Chris@16
|
55 == sizeof( type_traits::yes_type ) );
|
Chris@16
|
56 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
Chris@16
|
57 #pragma warning(pop)
|
Chris@16
|
58 #endif
|
Chris@16
|
59
|
Chris@16
|
60 };
|
Chris@16
|
61
|
Chris@16
|
62 template< class T >
|
Chris@16
|
63 struct remove_nullable
|
Chris@16
|
64 {
|
Chris@16
|
65 typedef BOOST_DEDUCED_TYPENAME mpl::eval_if< is_nullable<T>,
|
Chris@16
|
66 T,
|
Chris@16
|
67 mpl::identity<T> >::type
|
Chris@16
|
68 type;
|
Chris@16
|
69 };
|
Chris@16
|
70
|
Chris@16
|
71 }
|
Chris@16
|
72
|
Chris@16
|
73 #endif
|