Community
cancel
Showing results for 
Search instead for 
Did you mean: 
woodbird
Beginner
116 Views

Intel C++ 2016 std::function error

The following minimal working example fails to compile with the latest 2016 Update 2 on OS X 10.11.3 with Xcode 7.2.1,

 

#include <functional>

template <typename T>
class C
{
    public:
    using eval_type = std::function<double(const T &)>;

    void set_eval(const eval_type &eval) { eval_ = eval; }

    void eval(const T &val) { eval_(val); }

    private:
    eval_type eval_;
};

int main() { C<double> c; }

This kind of use of std::function works with previous versions of Intel C++ in C++11 mode and it still works with Intel C++ for Linux on latest CentOS.

The error message is as the following,

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/type_traits(3504): error: more than one instance of overloaded function "std::__1::__invoke" matches the argument list:
            function template "auto std::__1::__invoke(_Fp &&, _Args &&...)->decltype((<expression>))"
            function template "auto std::__1::__invoke(_Fp &&, _Args &&...)->decltype((<expression>))"
            argument types are: (std::__1::function<double (const double &)>, const double)
              __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
              ^
          detected during:
            instantiation of class "std::__1::__invokable_imp<_Fp, _Args...> [with _Fp=std::__1::function<double (const double &)> &, _Args=<const double &>]" at line 3512
            instantiation of class "std::__1::__invokable<_Fp, _Args...> [with _Fp=std::__1::function<double (const double &)> &, _Args=<const double &>]" at line 15 of "test.cpp"
            instantiation of class "C<T> [with T=double]" at line 17 of "test.cpp"

compilation aborted for test.cpp (code 2)

It looks like the compiler is trying to instantiate some functions it should not.

0 Kudos
2 Replies
Judith_W_Intel
Employee
116 Views

 

I have confirmed that this was fixed shortly after 16.0 update 2 was released by the fix for DPD200381052.

I think you can workaround the bug by compiling with the flag  -D_LIBCPP_HAS_NO_VARIADICS.

Sorry for the trouble, this will be fixed in update 3.

Judy

woodbird
Beginner
116 Views

Unfortunately I cannot use this workaround. This macro cause the standard library has no std::tuple, which I also use a lot.

For now I will revert back to update 1. 

Reply