【发布时间】:2010-01-22 22:33:32
【问题描述】:
基本上,我正在寻找这样的库解决方案:
#include <boost/type_traits.hpp>
template<bool>
struct bool_to_bool_type;
template<>
struct bool_to_bool_type<false>
{
typedef boost::false_type type;
};
template<>
struct bool_to_bool_type<true>
{
typedef boost::true_type type;
};
有这样的元函数吗?
【问题讨论】:
-
你想用这个达到什么目的?
-
@AraK:创建新类型特征时,您需要知道这一点。我做了几个。此外,有时我们只是希望将常量转换为类型,以选择不同的功能。
-
@GMan 谢谢。元编程是我的眼睛在 C++ 中看不到的阴暗面 :)
-
@AraK:有朝一日,纯净之光可以照进广阔的 C++,让你看到真相。
标签: c++ boost metaprogramming