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

(c++11) issues with using pointer to local function as template argument

$
0
0

Hi,

Trying to compile the following code:

#include <iostream>
using namespace std;


template<void (*F)()> void SetCallback(){
	F();
}

static void Foo() {
	struct stub_t {
		static void cb(){
			cout << "Foo::stub_t::cb()"<< endl;
		}
	};
	SetCallback<&stub_t::cb>();
}

void TemplateInstantiation() {
	Foo();
}

I get this error: "(18): error : a template argument may not reference a non-external entity".

But I can't find any restrictions on template arguments in c++11 specification, at least in draft n3376, that can explain why this is wrong.

Is there something that I have been missed? Or this is specific of the compiler?

I'm using Intel® C++ Composer XE 2015.


Viewing all articles
Browse latest Browse all 1665

Trending Articles



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