Is there a way to obtain the map type?

此生再无相见时 提交于 2019-12-06 16:35:56

If you really need the type beforehand here are two possible solutions:

  1. You could simply wrap the same expression in decltype.

    using MyMap = decltype(hana::make_map(
        hana::make_pair(hana::type_c<int>, 2),
        hana::make_pair(hana::type_c<char const*>, "hi"),
        hana::make_pair(hana::type_c<double>, 3.0)
    ));
    
  2. For your use case of using the same type as the key, you could make a simple type alias template.

    template <typename ...T>
    using type_map_t = decltype(hana::make_map(hana::make_pair(hana::type_c<T>, std::declval<T>())...));
    
    using MyMap = type_map_t<int, char const*, double>;
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!