source: NonGTP/Boost/boost/ptr_container/nullable.hpp @ 857

Revision 857, 1.6 KB checked in by igarcia, 19 years ago (diff)
Line 
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
25namespace 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            BOOST_STATIC_CONSTANT(bool, value = sizeof( ptr_container_detail::is_nullable( var ) )
49                                                == sizeof( type_traits::yes_type ) );
50    };
51   
52    template< class T >
53    struct remove_nullable
54    {
55        typedef BOOST_DEDUCED_TYPENAME mpl::eval_if< is_nullable<T>,
56                                                      T,
57                                            mpl::identity<T> >::type
58            type;
59    };
60
61}
62
63#endif
Note: See TracBrowser for help on using the repository browser.