Boost C++ 库

...世界上最受推崇、设计最精湛的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu, C++ Coding Standards

结构模板字面量 - Boost C++ 函数库
PrevUpHomeNext

结构模板字面量

boost::proto::literal — 对终端的简单包装,便于使用。

提要

// In header: <boost/proto/literal.hpp>

template<typename T, typename Domain = proto::default_domain> 
struct literal :  
  proto::extends<proto::basic_expr<proto::tag::terminal, proto::term< T > >, proto::literal<T, Domain>, Domain>
{
  // types
  typedef proto::basic_expr<proto::tag::terminal, proto::term< T > > X;                // For exposition only
  typedef typename proto::result_of::value<X>::type                  value_type;     
  typedef typename proto::result_of::value<X &>::type                reference;      
  typedef typename proto::result_of::value<X const &>::type          const_reference;

  // construct/copy/destruct
  literal();
  template<typename U> literal(U &);
  template<typename U> literal(U const &);
  template<typename U> literal(proto::literal< U, Domain > const &);

  // public member functions
  reference get();
  const_reference get() const;
};

描述

对终端的简单包装,便于使用。在所有情况下,proto::literal<X> l(x); 都等价于 proto::terminal<X>::type l = {x};

Domain 模板参数默认为 proto::default_domain

literal 公共构造/复制/析构

  1. literal();
  2. template<typename U> literal(U & u);
  3. template<typename U> literal(U const & u);
  4. template<typename U> literal(proto::literal< U, Domain > const & u);

literal 公共成员函数

  1. reference get();

    返回

    proto::value(*this)
  2. const_reference get() const;

    返回

    proto::value(*this)

PrevUpHomeNext