]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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/ | |
10 | // | |
11 | ||
12 | ||
13 | #ifndef BOOST_INDIRECT_CONTAINER_NULLABLE_HPP | |
14 | #define BOOST_INDIRECT_CONTAINER_NULLABLE_HPP | |
15 | ||
16 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) | |
17 | # pragma once | |
18 | #endif | |
19 | ||
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> | |
24 | ||
25 | namespace boost | |
26 | { | |
27 | ||
28 | template< class T > | |
29 | struct nullable | |
30 | { | |
31 | typedef T type; | |
32 | }; | |
33 | ||
34 | namespace ptr_container_detail | |
35 | { | |
36 | template< class T > | |
37 | type_traits::yes_type is_nullable( const nullable<T>* ); | |
38 | ||
39 | type_traits::no_type is_nullable( ... ); | |
40 | } | |
41 | ||
42 | template< class T > | |
43 | struct is_nullable | |
44 | { | |
45 | private: | |
46 | BOOST_STATIC_CONSTANT( T*, var ); | |
47 | public: | |
48 | ||
49 | #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) | |
50 | #pragma warning(push) | |
51 | #pragma warning(disable:6334) | |
52 | #endif | |
53 | ||
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 | |
59 | ||
60 | }; | |
61 | ||
62 | template< class T > | |
63 | struct remove_nullable | |
64 | { | |
65 | typedef BOOST_DEDUCED_TYPENAME mpl::eval_if< is_nullable<T>, | |
66 | T, | |
67 | mpl::identity<T> >::type | |
68 | type; | |
69 | }; | |
70 | ||
71 | } | |
72 | ||
73 | #endif |