Skip to content

Some test cases didn't compiled with VS 2019 #6

@X1aomu

Description

@X1aomu

See conan-io/conan-center-index#23477

Caused by a problem related to MSVC. The compiler fix is only available in v143 and up. So we need making changes in our code.

Minimum code to reproduce
#include <type_traits>

template<class T, template<class...> class Template>
inline constexpr bool is_specialization_v = false;
template<template<class...> class Template, class... Types>
inline constexpr bool is_specialization_v<Template<Types...>, Template> = true;

template<class T, class U>
struct MyType
{
    template<class Fn>
    void Func(Fn&& f)
    {
        using RetType = std::remove_cvref_t<std::invoke_result_t<Fn>>;
        static_assert(is_specialization_v<RetType, MyType>);
    }
};

template<class U>
struct MyType<void, U>
{
    template<class Fn>
    void Func(Fn&& f)
    {
        using RetType = std::remove_cvref_t<std::invoke_result_t<Fn>>;
        static_assert(is_specialization_v<RetType, MyType>);
    }
};

template<class U>
struct MyType<double, U>
{
    template<class Fn>
    void Func(Fn&& f)
    {
        using RetType = std::remove_cvref_t<std::invoke_result_t<Fn>>;
        static_assert(is_specialization_v<RetType, MyType>);
    }
};

int main(int argc, char* argv[])
{
    {
        using T = MyType<int, int>;
        T v;
        v.Func([]() { return T {}; }); // #1 compiled
    }
    {
        using T = MyType<void, int>;
        T v;
        v.Func([]() { return T {}; }); // #2 do not compiled
    }
    {
        using T = MyType<double, int>;
        T v;
        v.Func([]() { return T {}; }); // #3 do not compiled
    }
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions