$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] [TypeTraits] Is it possible to detect that type is	not exist and use default type?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-06-30 15:40:18
AMDG
Sakharuk, Vlad (GMI Development) wrote:
> Here is example:
> class one {
>     public:
>     typedef someclass internal;
> };
>  
> class two {
> // No internal class
> };
>  
> class default_internal{
> };
>  
> I would like to be able to write something if it possible:
>  
> template<class T, class B = if_exist(T::internal)  T::internal else
> default_internal > class proc {
> };
>  
> So I can use proc with both
>  
> proc<one> One;
> proc<two> Two;
>  
> without specifying derived type? 
Use BOOST_MPL_HAS_XXX_TRAIT_DEF with boost::mpl::eval_if.
#include <boost/mpl/has_xxx.hpp>
#include <boost/mpl/eval_if.hpp>
BOOST_MPL_HAX_XXX_TRAIT_DEF(internal)
template<class T>
struct get_internal {
    typedef typename T::internal type;
};
template<
    class T,
    class B = typename boost::mpl::eval_if<has_internal<T>,
        get_internal<T>,
        boost::mpl::identity<default_internal>
    >::type
 >
class proc;
In Christ,
Steven Watanabe