add tag
Jonathan Mee
I posted a solution to this problem: But found my answer only works in GCC. The function definition looks like:

    template <template <typename> class L, template <typename> class R, typename T>
    std::conditional_t<std::is_same_v<L<T>, R<T>>, std::true_type, std::false_type> IsSameContainer(const R<T>&);

I've even simplified the execution code to just deriving a variable:

    const auto test = decltype(IsSameContainer<std::vector>(param))::value

This still fails to compile on all but GCC. Does anyone have suggestions on how to make the function cross-platform?

[**Live Example**](
Top Answer
Jonathan Mee
This can be can be solved by accepting all template parameters rather than just the un-defaulted template parameter:

    template <template <typename...> class L, template <typename...> class R, typename... T>
    std::conditional_t<std::is_same_v<L<T...>, R<T...>>, std::true_type, std::false_type> IsSameContainer(const R<T...>&);

This will allow compilation on Clang as well:
It can be convenient to define a templatized variable for this type as well:

    template <template <typename...> class L, typename T>
    static constexpr const auto is_same_container_v = decltype(IsSameContainer<L>(std::declval<T>()))::value;

Strangely Visual Studio will only allow my updated version of `IsSameContainer` if it is accessed through the templatized variable:

This room is for discussion about this question.

Once logged in you can direct comments to any contributor here.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.