std 或 boost 在<T>某处有标签或type_t<T>吗?

Do std or boost have tag<T> or type_t<T> somewhere?

本文关键字:lt gt type 标签 boost std      更新时间:2023-10-16

具体来说,我正在寻找类似这种结构的东西:

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

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

> c++20 将具有std::type_identity

Boost已经boost::type_identity

std::in_place_type_t作为

构造函数的标记类型可能更可取。它由std::any的构造函数和std::variant的构造函数使用。

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