source: NonGTP/Boost/boost/iostreams/detail/bool_trait_def.hpp @ 857

Revision 857, 1.9 KB checked in by igarcia, 18 years ago (diff)
Line 
1// (C) Copyright Jonathan Turkanis 2003.
2// Distributed under the Boost Software License, Version 1.0. (See accompanying
3// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
4
5// See http://www.boost.org/libs/iostreams for documentation.
6
7#ifndef BOOST_IOSTREAMS_DETAIL_BOOL_TRAIT_DEF_HPP_INCLUDED
8#define BOOST_IOSTREAMS_DETAIL_BOOL_TRAIT_DEF_HPP_INCLUDED     
9
10#include <boost/config.hpp> // BOOST_STATIC_CONSTANT.
11#include <boost/iostreams/detail/template_params.hpp>
12#include <boost/mpl/aux_/lambda_support.hpp>
13#include <boost/mpl/bool.hpp>
14#include <boost/preprocessor/cat.hpp>
15#include <boost/preprocessor/repetition/enum_params.hpp>
16#include <boost/type_traits/detail/yes_no_type.hpp>
17 
18//
19// Macro name: BOOST_IOSTREAMS_BOOL_TRAIT_DEF
20// Description: Used to generate the traits classes is_istream, is_ostream,
21//      etc.
22//
23#if BOOST_WORKAROUND(__BORLANDC__, <= 0x564)
24# define BOOST_IOSTREAMS_TRAIT_NAMESPACE(trait)
25#else
26# define BOOST_IOSTREAMS_TRAIT_NAMESPACE(trait) BOOST_PP_CAT(trait, _impl_)::
27#endif
28#define BOOST_IOSTREAMS_BOOL_TRAIT_DEF(trait, type, arity) \
29    namespace BOOST_PP_CAT(trait, _impl_) { \
30      BOOST_IOSTREAMS_TEMPLATE_PARAMS(arity, T) \
31      type_traits::yes_type helper \
32          (const volatile type BOOST_IOSTREAMS_TEMPLATE_ARGS(arity, T)*); \
33      type_traits::no_type helper(...); \
34      template<typename T> \
35      struct impl { \
36           BOOST_STATIC_CONSTANT(bool, value = \
37           (sizeof(BOOST_IOSTREAMS_TRAIT_NAMESPACE(trait) \
38              helper(static_cast<T*>(0))) == \
39                sizeof(type_traits::yes_type))); \
40      }; \
41    } \
42    template<typename T> \
43    struct trait \
44        : mpl::bool_<BOOST_PP_CAT(trait, _impl_)::impl<T>::value> \
45    { BOOST_MPL_AUX_LAMBDA_SUPPORT(1, trait, (T)) }; \
46    /**/
47
48#endif // #ifndef BOOST_IOSTREAMS_DETAIL_BOOL_TRAIT_DEF_HPP_INCLUDED
Note: See TracBrowser for help on using the repository browser.