Quantcast
Channel: Intel® C++-Compiler
Viewing all articles
Browse latest Browse all 1665

Intel C++ 2016 std::function error

$
0
0

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.


Viewing all articles
Browse latest Browse all 1665

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>