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