Off-Topic is a silly close reason for this question. If I'd done anything with this question, I would have closed as "Too Broad".
But let's suppose instead I tried to answer it. Actually, let's not suppose; let's do it!
OK, so I don't know anything about that error message, but I'm pretty good with C++ and I know how to Google:
- Error with using a function as a non-type template parameter
hmm, this person's problem was down to a simple template mismatch in their code (they swapped some parameters accidentally). Maybe your code has a similar problem? If there were an MVCE, I could check this assumption and get back to you with an answer.
- http://microsoft.public.vc.stl.narkive.com/S4mncifz/problem-compiling-template
looks like this time it was something rather different, related to using const char *
as a template argument (something I didn't know was possible!). They solved it by making their variable extern
. Well, this looks totally different to the first issue… If only there were an MVCE so that I could quickly check if you had some kind of pointer in your template arguments, which might hint that this is the more likely issue.
Interestingly: reveals that VC's equivalent error is "an expression involving objects with internal linkage cannot be used as a non-type"
- https://software.intel.com/en-us/forums/intel-c-compiler/topic/514793
wow, function pointers in templates now? I'm learning all kinds of things! OK so they're talking about a behaviour change going into C++11. Man, it'd be nice to know if you're pre- or post- C++11 - that could save me some time! Oh well. They link to a SO answer explaining the change, so let's look at that.
- Why did C++03 require template parameters to have external linkage?
oh hey, it's our very own Lightness Races in Orbit. There's a concrete example of potentially bad behaviour in the answer… From a cursory glance, it looks like there's an issue if you have an extern template (i.e. one we promise to define in another compilation unit) which, when defined, tries to use something which would be hidden from other compilation units (that the template isn't hidden from). Makes sense I guess. But it sounds like they spec'd it restrictively so that even non-extern templates get the same rules. I wonder if you're trying to do something like this? From the looks of the earlier bug report, it sounds like if you are, you might be in a twilight zone of some compiler's accepting it and others rejecting it! I'd love to help you out of a twilight zone, but I don't have a clue if it's anywhere near relevant to you.
Let's take a step back and search around Visual C++'s name for the error:
- Passing a structure as a template-parameter - How can I fix this code?
Oh OK. So this is yet another situation which is causing the same error. Now they're trying to pick a template using what they assume are const values (in this case: which have been passed through a struct first). Feels like the kind of thing constexpr
was brought in to help with. Maybe you're trying to do something like this? It feels similar to using strings and function pointers…
I think I'm getting an idea of what the underlying error is now, since most of these have some themes in common. Let's see if I can explain it with any clarity:
You have tried to use a value which won't be available to other compilation units (a "non-external entity") as a template argument.
Hmm, that… actually sounds a lot like the message you're already seeing. Maybe if I knew exactly which part you're unclear on I could try to expand on it; I guess I explained roughly what a non-external entity is. And if your actual problem was closer to the first thing I found, you'll be absolutely no closer to fixing it. I should expand my answer:
Or you could trigger this if you mis-match function arguments when you instantiate your template.
Well that still doesn't cover the whole extern template
stuff I saw. I should expand my answer:
Or you could trigger this if you try to use a static function in your template's code and you're pre-C++11.
But those are both way too specific for a guess-answer. I imagine I'm only scratching the surface of possible unrelated causes.
Oh also maybe you're dealing with the compiler twilight zone issue? I should expand my answer:
In C++11 the spec made a change to this behaviour which may have been slow to propagate to all compilers. For example, Intel's compiler will spuriously produce this warning when it shouldn't (see https://software.intel.com/en-us/forums/intel-c-compiler/topic/514793). If you're using such a compiler, you should upgrade or switch, or work around it somehow.
Dang, now I've given 4 separate explanations and solutions. 3 of them are super-specific to situations which probably don't apply to you, and the first hardly alters the message you're already seeing. This is a terrible answer.
Nevermind, guess I can't help you. Oh well, I would only have wasted those hours anyway.
TL;DR: Asking for a MVCE / SSCCE isn't just pedantry; it's genuinely required for diagnosing even seemingly generic abstract problems. If I don't have anything to check on / experiment with / test assumptions against, how can I know what information is most relevant? How can I know what you're trying to accomplish?
And if you think an error message is something concrete with a unique explanation, just take a look at the books written here: What is a NullPointerException, and how do I fix it?