C++ 这是std::bind的错误使用还是编译器错误?

C++ 这是std::bind的错误使用还是编译器错误?,c++,c++11,clang,mingw,C++,C++11,Clang,Mingw,我正在使用带有最新TDM Gcc头和LIB的clang的最新快照构建。编译时(使用-std=c++11标志): #包括 #包括 福班 { 公众: 空栏(整数x) { std::cout此代码很好。 除非你在安装过程中做了一些奇怪或不受支持的事情,否则你的工具链就有一个bug 在我看来,它似乎没有将std::bind的第二个参数视为“this pointer”,而是认为您实际上在将两个参数传递给Foo::Bar(您不是),而您不能 下一步是向工具链的维护人员提出这个问题 请参阅。所以我想这是一个叮

我正在使用带有最新TDM Gcc头和LIB的clang的最新快照构建。编译时(使用-std=c++11标志):

#包括
#包括
福班
{
公众:
空栏(整数x)
{

std::cout此代码很好。

除非你在安装过程中做了一些奇怪或不受支持的事情,否则你的工具链就有一个bug

在我看来,它似乎没有将
std::bind
的第二个参数视为“this pointer”,而是认为您实际上在将两个参数传递给
Foo::Bar
(您不是),而您不能

下一步是向工具链的维护人员提出这个问题


请参阅。

所以我想这是一个叮当作响的bug?我不想这么快就称之为bug。检查您的环境,我可能有什么问题。我在windows上遇到了这个问题。叮当的windows对libstdc++的实现甚至还没有完成……即使使用GCC头叮当作响,它对我也有效,以防这还不清楚。。我只在使用mingw32头文件和clangx86时遇到这种情况,但在使用mingw64头文件和clangx64时效果很好。
#include <functional>
#include <iostream>

class Foo
{
    public:
        void Bar(int x)
        {
            std::cout << x << std::endl;
        }
};

int main()
{
    Foo foo;
    auto f = std::bind(&Foo::Bar, &foo, 5);
    f();
    return 0;
}
In file included from Test.cpp:1:
C:\DevEnv\LLVM38\lib\gcc\mingw32\5.1.0\include\c++\functional:1426:7: error: static_assert failed "Wrong number of arguments for pointer-to-member"
      static_assert(_Varargs::value
      ^             ~~~~~~~~~~~~~~~
C:\DevEnv\LLVM38\lib\gcc\mingw32\5.1.0\include\c++\functional:1440:7: note: in instantiation of template class 'std::_Bind_check_arity<void (Foo::*)(int) __attribute__((thiscall)), Foo *, int>' requested here
    : _Bind_check_arity<typename decay<_Func>::type, _BoundArgs...>
      ^
C:\DevEnv\LLVM38\lib\gcc\mingw32\5.1.0\include\c++\functional:1461:5: note: in instantiation of template class 'std::_Bind_helper<false, void (Foo::*)(int) __attribute__((thiscall)), Foo *, int>' requested here
    _Bind_helper<__is_socketlike<_Func>::value, _Func, _BoundArgs...>::type
    ^
Test.cpp:16:14: note: while substituting deduced template arguments into function template 'bind' [with _Func = void (Foo::*)(int) __attribute__((thiscall)), _BoundArgs = <Foo *, int>]
    auto f = std::bind(&Foo::Bar, &foo, 5);
             ^
Test.cpp:16:14: error: no matching function for call to 'bind'
    auto f = std::bind(&Foo::Bar, &foo, 5);
             ^~~~~~~~~
C:\DevEnv\LLVM38\lib\gcc\mingw32\5.1.0\include\c++\functional:1490:5: note: candidate template ignored: couldn't infer template argument '_Result'
    bind(_Func&& __f, _BoundArgs&&... __args)
    ^
C:\DevEnv\LLVM38\lib\gcc\mingw32\5.1.0\include\c++\functional:1462:5: note: candidate template ignored: substitution failure [with _Func = void (Foo::*)(int) __attribute__((thiscall)), _BoundArgs = <Foo *, int>]
    bind(_Func&& __f, _BoundArgs&&... __args)
    ^
2 errors generated.