Boost C++ 库

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

类 postconstructor_invoker - Boost C++ 函数库
PrevUpHomeNext

类 postconstructor_invoker

boost::signals2::postconstructor_invoker — 为使用 deconstruct() 创建的对象传递参数并运行后构造函数。

提要

// In header: <boost/signals2/deconstruct.hpp>


class postconstructor_invoker {
public:

  // public methods
  operator const shared_ptr<T> &();
  const shared_ptr<T> & postconstruct();
  template<typename A1> const shared_ptr<T> & postconstruct(A1);
  template<typename A1, typename A2> 
    const shared_ptr<T> & postconstruct(A1, A1);
  template<typename A1, typename A2, ..., typename AN> 
    const shared_ptr<T> & postconstruct(A1, A1, ..., A1);
};

描述

类型为 postconstructor_invoker 的对象由调用 deconstruct() 工厂函数返回。这些对象旨在立即赋值给 shared_ptr(在这种情况下,类的转换运算符将通过调用 postconstruct 来执行转换,不带参数),或者由用户通过显式调用 postconstruct 方法之一将其转换为 shared_ptr。

postconstructor_invoker 公共方法

  1. operator const shared_ptr<T> &();

    转换运算符的效果与显式调用不带参数的 postconstruct 方法相同。

  2. const shared_ptr<T> & postconstruct();
    template<typename A1> const shared_ptr<T> & postconstruct(A1 a1);
    template<typename A1, typename A2> 
      const shared_ptr<T> & postconstruct(A1 a1, A1 a2);
    template<typename A1, typename A2, ..., typename AN> 
      const shared_ptr<T> & postconstruct(A1 a1, A1 a2, ..., A1 aN);

    postconstruct 方法会无限定地调用 adl_postconstruct(),然后返回由 deconstruct() 封装在 postconstructor_invoker 对象中的 shared_ptr。传递给 adl_postconstruct() 调用的前两个参数始终是 deconstruct() 创建的对象的拥有者 shared_ptr,然后是同一个对象的普通指针。为了方便起见,普通指针将始终被转换为指向非 const 类型的指针,然后再传递给 adl_postconstruct。传递给 adl_postconstruct 的其余参数是用户可能传递给 postconstruct 方法的任何参数。


PrevUpHomeNext