MSVC fails to deduce template argument for std::vector<std::reference_wrapper<const T>>

Viewed 63

This code compiles fine with GCC and Clang.
But does not compile with MSVC. https://godbolt.org/z/h4oM1oe35

#include <vector>
#inlcude <functional>

template <typename ItemT, template <typename...> class ContainerT>
void msvc_fails(const ContainerT<std::reference_wrapper<const ItemT>> &){}

template <typename ItemT>
void msvc_works(const std::vector<std::reference_wrapper<const ItemT>> &)
{}

template <typename ItemT, template <typename...> class ContainerT>
void msvc_fails_also(const ContainerT<const ItemT*> &)
{}


int main()
{
    struct item{};
    const auto &vec = std::vector<std::reference_wrapper<const item>>();

    msvc_fails(vec);
    msvc_works(vec);

    const auto &vecPtr = std::vector<const item*>();
    msvc_fails_also(vecPtr);
    
    return 0;
}

Is this a bug in MSVC?

0 Answers
Related