Boost C++ 库

...世界上最受推崇和设计精良的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu,《C++ 编码规范

结构模板字面量 - 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