代码之家  ›  专栏  ›  技术社区  ›  darune

std或boost是否在某个地方有tag<t>或type_t<t>标记?

  •  1
  • darune  · 技术社区  · 6 年前

    具体来说,我正在寻找类似这样的构造:

    template<class T>
    struct tag {
      using type = T;
    };
    

    这可用于向构造函数提供模板参数。

    3 回复  |  直到 6 年前
        1
  •  3
  •   cpplearner    6 年前

    std::in_place_type_t 可能更适合作为构造函数的标记类型。它被使用 std::any 's constructors std::variant 's constructors .

        3
  •  2
  •   lubgr    6 年前

    看一看 std::type_identity . 示例实现正是您发布的代码片段。