1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/mpl/has_xxx.hpp Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,233 @@
1.4 +
1.5 +#ifndef BOOST_MPL_HAS_XXX_HPP_INCLUDED
1.6 +#define BOOST_MPL_HAS_XXX_HPP_INCLUDED
1.7 +
1.8 +// Copyright Aleksey Gurtovoy 2002-2006
1.9 +// Copyright David Abrahams 2002-2003
1.10 +//
1.11 +// Distributed under the Boost Software License, Version 1.0.
1.12 +// (See accompanying file LICENSE_1_0.txt or copy at
1.13 +// http://www.boost.org/LICENSE_1_0.txt)
1.14 +//
1.15 +// See http://www.boost.org/libs/mpl for documentation.
1.16 +
1.17 +// $Source: /cvsroot/boost/boost/boost/mpl/has_xxx.hpp,v $
1.18 +// $Date: 2006/11/09 01:05:31 $
1.19 +// $Revision: 1.4.6.1 $
1.20 +
1.21 +#include <boost/mpl/bool.hpp>
1.22 +#include <boost/mpl/aux_/type_wrapper.hpp>
1.23 +#include <boost/mpl/aux_/yes_no.hpp>
1.24 +#include <boost/mpl/aux_/config/has_xxx.hpp>
1.25 +#include <boost/mpl/aux_/config/msvc_typename.hpp>
1.26 +#include <boost/mpl/aux_/config/msvc.hpp>
1.27 +#include <boost/mpl/aux_/config/static_constant.hpp>
1.28 +#include <boost/mpl/aux_/config/workaround.hpp>
1.29 +
1.30 +#include <boost/preprocessor/cat.hpp>
1.31 +
1.32 +#if !defined(BOOST_MPL_CFG_NO_HAS_XXX)
1.33 +
1.34 +# if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
1.35 +
1.36 +// agurt, 11/sep/02: MSVC-specific version (< 7.1), based on a USENET
1.37 +// newsgroup's posting by John Madsen (comp.lang.c++.moderated,
1.38 +// 1999-11-12 19:17:06 GMT); the code is _not_ standard-conforming, but
1.39 +// it works way more reliably than the SFINAE-based implementation
1.40 +
1.41 +// Modified dwa 8/Oct/02 to handle reference types.
1.42 +
1.43 +# include <boost/mpl/if.hpp>
1.44 +# include <boost/mpl/bool.hpp>
1.45 +
1.46 +namespace boost { namespace mpl { namespace aux {
1.47 +
1.48 +struct has_xxx_tag;
1.49 +
1.50 +#if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
1.51 +template< typename U > struct msvc_incomplete_array
1.52 +{
1.53 + typedef char (&type)[sizeof(U) + 1];
1.54 +};
1.55 +#endif
1.56 +
1.57 +template< typename T >
1.58 +struct msvc_is_incomplete
1.59 +{
1.60 + // MSVC is capable of some kinds of SFINAE. If U is an incomplete
1.61 + // type, it won't pick the second overload
1.62 + static char tester(...);
1.63 +
1.64 +#if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
1.65 + template< typename U >
1.66 + static typename msvc_incomplete_array<U>::type tester(type_wrapper<U>);
1.67 +#else
1.68 + template< typename U >
1.69 + static char (& tester(type_wrapper<U>) )[sizeof(U)+1];
1.70 +#endif
1.71 +
1.72 + BOOST_STATIC_CONSTANT(bool, value =
1.73 + sizeof(tester(type_wrapper<T>())) == 1
1.74 + );
1.75 +};
1.76 +
1.77 +template<>
1.78 +struct msvc_is_incomplete<int>
1.79 +{
1.80 + BOOST_STATIC_CONSTANT(bool, value = false);
1.81 +};
1.82 +
1.83 +}}}
1.84 +
1.85 +# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF_(trait, name, default_) \
1.86 +template< typename T, typename name = ::boost::mpl::aux::has_xxx_tag > \
1.87 +struct BOOST_PP_CAT(trait,_impl) : T \
1.88 +{ \
1.89 + static boost::mpl::aux::no_tag \
1.90 + test(void(*)(::boost::mpl::aux::has_xxx_tag)); \
1.91 + \
1.92 + static boost::mpl::aux::yes_tag test(...); \
1.93 + \
1.94 + BOOST_STATIC_CONSTANT(bool, value = \
1.95 + sizeof(test(static_cast<void(*)(name)>(0))) \
1.96 + != sizeof(boost::mpl::aux::no_tag) \
1.97 + ); \
1.98 + typedef boost::mpl::bool_<value> type; \
1.99 +}; \
1.100 +\
1.101 +template< typename T, typename fallback_ = boost::mpl::bool_<default_> > \
1.102 +struct trait \
1.103 + : boost::mpl::if_c< \
1.104 + boost::mpl::aux::msvc_is_incomplete<T>::value \
1.105 + , boost::mpl::bool_<false> \
1.106 + , BOOST_PP_CAT(trait,_impl)<T> \
1.107 + >::type \
1.108 +{ \
1.109 +}; \
1.110 +\
1.111 +BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, void) \
1.112 +BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, bool) \
1.113 +BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, char) \
1.114 +BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, signed char) \
1.115 +BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, unsigned char) \
1.116 +BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, signed short) \
1.117 +BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, unsigned short) \
1.118 +BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, signed int) \
1.119 +BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, unsigned int) \
1.120 +BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, signed long) \
1.121 +BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, unsigned long) \
1.122 +BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, float) \
1.123 +BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, double) \
1.124 +BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, long double) \
1.125 +/**/
1.126 +
1.127 +# define BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, T) \
1.128 +template<> struct trait<T> \
1.129 +{ \
1.130 + BOOST_STATIC_CONSTANT(bool, value = false); \
1.131 + typedef boost::mpl::bool_<false> type; \
1.132 +}; \
1.133 +/**/
1.134 +
1.135 +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
1.136 +# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, unused) \
1.137 + BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF_(trait, name, unused) \
1.138 + BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, wchar_t) \
1.139 +/**/
1.140 +#else
1.141 +# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, unused) \
1.142 + BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF_(trait, name, unused) \
1.143 +/**/
1.144 +#endif
1.145 +
1.146 +
1.147 +// SFINAE-based implementations below are derived from a USENET newsgroup's
1.148 +// posting by Rani Sharoni (comp.lang.c++.moderated, 2002-03-17 07:45:09 PST)
1.149 +
1.150 +# elif BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) \
1.151 + || BOOST_WORKAROUND(__IBMCPP__, <= 700)
1.152 +
1.153 +// MSVC 7.1+ & VACPP
1.154 +
1.155 +// agurt, 15/jun/05: replace overload-based SFINAE implementation with SFINAE
1.156 +// applied to partial specialization to fix some apparently random failures
1.157 +// (thanks to Daniel Wallin for researching this!)
1.158 +
1.159 +namespace boost { namespace mpl { namespace aux {
1.160 +template< typename T > struct msvc71_sfinae_helper { typedef void type; };
1.161 +}}}
1.162 +
1.163 +# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, default_) \
1.164 +template< typename T, typename U = void > \
1.165 +struct BOOST_PP_CAT(trait,_impl_) \
1.166 +{ \
1.167 + BOOST_STATIC_CONSTANT(bool, value = false); \
1.168 + typedef boost::mpl::bool_<value> type; \
1.169 +}; \
1.170 +\
1.171 +template< typename T > \
1.172 +struct BOOST_PP_CAT(trait,_impl_)< \
1.173 + T \
1.174 + , typename boost::mpl::aux::msvc71_sfinae_helper< typename T::name >::type \
1.175 + > \
1.176 +{ \
1.177 + BOOST_STATIC_CONSTANT(bool, value = true); \
1.178 + typedef boost::mpl::bool_<value> type; \
1.179 +}; \
1.180 +\
1.181 +template< typename T, typename fallback_ = boost::mpl::bool_<default_> > \
1.182 +struct trait \
1.183 + : BOOST_PP_CAT(trait,_impl_)<T> \
1.184 +{ \
1.185 +}; \
1.186 +/**/
1.187 +
1.188 +# else // other SFINAE-capable compilers
1.189 +
1.190 +# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, default_) \
1.191 +template< typename T, typename fallback_ = boost::mpl::bool_<default_> > \
1.192 +struct trait \
1.193 +{ \
1.194 + struct gcc_3_2_wknd \
1.195 + { \
1.196 + template< typename U > \
1.197 + static boost::mpl::aux::yes_tag test( \
1.198 + boost::mpl::aux::type_wrapper<U> const volatile* \
1.199 + , boost::mpl::aux::type_wrapper<BOOST_MSVC_TYPENAME U::name>* = 0 \
1.200 + ); \
1.201 + \
1.202 + static boost::mpl::aux::no_tag test(...); \
1.203 + }; \
1.204 + \
1.205 + typedef boost::mpl::aux::type_wrapper<T> t_; \
1.206 + BOOST_STATIC_CONSTANT(bool, value = \
1.207 + sizeof(gcc_3_2_wknd::test(static_cast<t_*>(0))) \
1.208 + == sizeof(boost::mpl::aux::yes_tag) \
1.209 + ); \
1.210 + typedef boost::mpl::bool_<value> type; \
1.211 +}; \
1.212 +/**/
1.213 +
1.214 +# endif // BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
1.215 +
1.216 +
1.217 +#else // BOOST_MPL_CFG_NO_HAS_XXX
1.218 +
1.219 +// placeholder implementation
1.220 +
1.221 +# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, default_) \
1.222 +template< typename T, typename fallback_ = boost::mpl::bool_<default_> > \
1.223 +struct trait \
1.224 +{ \
1.225 + BOOST_STATIC_CONSTANT(bool, value = fallback_::value); \
1.226 + typedef fallback_ type; \
1.227 +}; \
1.228 +/**/
1.229 +
1.230 +#endif
1.231 +
1.232 +#define BOOST_MPL_HAS_XXX_TRAIT_DEF(name) \
1.233 + BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(BOOST_PP_CAT(has_,name), name, false) \
1.234 +/**/
1.235 +
1.236 +#endif // BOOST_MPL_HAS_XXX_HPP_INCLUDED