- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following code fails to compile with Intel C++ 17.0 but compiles fine with MSVC & gcc. If I use a typedef instead of decltype, then it compiles OK.
#include <iostream> template<class Sig, Sig Func> struct MyFunc; template<class T, class... Args, void (T::*Func)(Args...) const> struct MyFunc<void (T::*)(Args...) const, Func> { static void execute(const T *obj, Args... args) { (obj->*Func)(args...); } }; template<class T, class... Args, void (T::*Func)(Args...)> struct MyFunc<void (T::*)(Args...), Func> { static void execute(T *obj, Args... args) { (obj->*Func)(args...); } }; #define MYFUNC(...) MyFunc<decltype(__VA_ARGS__), __VA_ARGS__> struct A { void func() const { std::cout << "in A::func() const" << std::endl; } void func() { std::cout << "in A::func()" << std::endl; } }; int main() { A a; MYFUNC(static_cast<void(A::*)() const>(&A::func))::execute(&a); MYFUNC(static_cast<void(A::*)()>(&A::func))::execute(&a); };
- Tags:
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What GCC version and the command line options did you use?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is compiling with the following compilers:
- gcc 6.3.0 (with no special compilation flags, or with -std=c++11)
- Visual Studio 17.0 (with no special compilation flags)
It is failing with Intel 19.0 Update 3 (Windows) with /Qstd=c++14 but seems to work with /Qstd=c++17.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page