Boost库中的type_erasure模块提供了一种基于类型擦除的方式来实现多态行为。type_erasure中的negatable概念是用来表示一个可否定的类型,即该类型可以取反。接下来我们将介绍如何使用negatable相关的测试程序。
在使用type_erasure的过程中,我们需要定义一些概念并将其注册到type_erasure的运行时系统中。negatable概念是其中之一,它可以被定义为一个类,并且需要提供一些接口函数。我们来看一个示例:
#include <boost/type_erasure/named_concept.hpp>
#include <boost/type_erasure/concept_interface.hpp>
#include <boost/type_erasure/tuple.hpp>
#include <boost/mpl/vector.hpp>
using namespace boost::type_erasure;
struct negatable_concept : named_concept<negatable_concept, "Negatable">
{
template<typename T>
struct apply
{
typedef typename T::negate_type type;
};
};
struct negateable
{
typedef boost::