Skip to content

Instantly share code, notes, and snippets.

@alifahrri
Created November 11, 2019 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alifahrri/622c6c58566b8efe5deb35c39db575ff to your computer and use it in GitHub Desktop.
Save alifahrri/622c6c58566b8efe5deb35c39db575ff to your computer and use it in GitHub Desktop.
namespace mpl {
    template <typename T, typename V, size_t, typename=void>
    struct copy_std_container {
        using type = std::enable_if_t<
            traits::is_std_array_or_vector<T>::value, std::vector<std::decay_t<V>>
        >;
    };
    template <typename T, typename V>
    struct copy_std_container<T,V,0,std::enable_if_t<traits::is_std_array<T>::value>> {
        using type = std::enable_if_t<
            traits::is_std_array_or_vector<T>::value, std::array<std::decay_t<V>,std::tuple_size<T>::value>
        >;
    };
    template <typename T, typename V, size_t n>
    struct copy_std_container<T,V,n,std::enable_if_t<traits::is_std_array<T>::value>> {
        using type = std::enable_if_t<
            traits::is_std_array_or_vector<T>::value, std::array<std::decay_t<V>,n>
        >;
    };
    template <typename T, typename V, size_t n=0>
    using copy_std_container_t = typename copy_std_container<T,V,n>::type;
} // namespace mpl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment