C++ 在Visual Studio 2015中,类会影响其他类的行为

C++ 在Visual Studio 2015中,类会影响其他类的行为,c++,visual-studio,visual-studio-2015,typetraits,C++,Visual Studio,Visual Studio 2015,Typetraits,我有以下代码来检测类型T是否具有具有特定返回类型和参数的函数(由一些更复杂的宏生成的简化版本): 编辑:我正在使用VS2019的最新版本和VisualStudio2015(v140)Toolchain。我不太确定在这种情况下如何检查版本编译器错误是什么?您还不知道工作环境吗?“如果我在有容量后移动有字节,代码将使用VS2015编译。”?@idclev463035818 consoleapplication1.cpp(51):错误C2338:应该有错误消息必须大于此值(或者VS比我想象的要糟糕得多

我有以下代码来检测类型
T
是否具有具有特定返回类型和参数的函数(由一些更复杂的宏生成的简化版本):


编辑:我正在使用VS2019的最新版本和
VisualStudio2015(v140)
Toolchain。我不太确定在这种情况下如何检查版本

编译器错误是什么?您还不知道工作环境吗?“如果我在有容量后移动有字节,代码将使用VS2015编译。”?@idclev463035818 consoleapplication1.cpp(51):错误C2338:应该有错误消息必须大于此值(或者VS比我想象的要糟糕得多)。请在问题中包含完整的错误信息,并将完整的错误日志作为文本而不是图片放在那里。编译器错误是什么?您还不知道工作情况吗?“如果我在有容量后移动有字节,代码将使用VS2015编译。”?@idclev463035818 consoleapplication1.cpp(51):错误C2338:应该有错误消息必须大于此值(或者VS比我想象的要糟糕得多)。请在问题中包含完整的错误信息,并将完整的错误日志作为文本而不是图片放在那里。
#include <vector>
#include <complex>
#include <type_traits>

namespace has_private
{
    template <typename...>
    using void_t = void;

    template <typename T>
    struct identity
    {
        using type = T;
    };

    template <typename T>
    struct add_const
    {
        using type = const T;
    };
}  // namespace has_private

template <typename T, typename = void>
struct has_bytes : std::false_type
{
    static_assert(sizeof(T) > 0, "Incomplete type");
};

template <typename T>
struct has_bytes<
    T,
    has_private::void_t<decltype(std::declval<typename has_private::add_const<T&>::type>().bytes())>>
    : std::is_same<decltype(std::declval<typename has_private::add_const<T&>::type>().bytes()), size_t>
{
};

template <typename T, typename = void>
struct has_capacity : std::false_type
{
    static_assert(sizeof(T) > 0, "Incomplete type");
};

template <typename T>
struct has_capacity<
    T,
    has_private::void_t<decltype(std::declval<typename has_private::add_const<T&>::type>().capacity())>>
    : std::is_same<decltype(std::declval<typename has_private::add_const<T&>::type>().capacity()), size_t>
{
};

static_assert(has_capacity<std::vector<int>>::value, "should have");
static_assert(has_capacity<std::complex<int>>::value == false, "shouldn't have");
1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------
1>ConsoleApplication1.cpp
1>source\repos\consoleapplication1\consoleapplication1\consoleapplication1.cpp(51): error C2338: should have
1>Done building project "ConsoleApplication1.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========