1

The company I work for has an API for mangling C++ symbols for a specific ABI.

I am trying to rewrite the API to make it more straightforward.

I have the following class template:

template <typename T> struct Symbolizer;

template <class Class_T, typename ReturnType_T>
struct Symbolizer<ReturnType_T (Class_T::*FuncPtr)()>
{
  std::string operator() ()
  {
    // ...
  }
};

template <class Class_T, typename ReturnType_T>
struct Symbolizer<ReturnType_T (Class_T::*FuncPtr)() const>
{
  std::string operator() ()
  {
    // ...
  }
};

So that one would mangle std::string::length this way:

Symbolizer<&std::string::length> symbolizer;
std::cout << symbolizer() << std::endl;

When I build it with g++, I get the following error:

error: ‘FuncPtr’ was not declared in this scope

G++ doesn't seem to understand I am declaring FuncPtr, and not using it.

Am I doing something wrong or is it just impossible to do it with c++?

One more info: I am stuck with c++ 98.

Antoine
  • 1,782
  • 1
  • 14
  • 32
  • 2
    This is impossible (prior to [n3601](http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3601.html)), you cannot deduce the type of a non-type template parameter. You need to explicitly supply `Class_T` and `ReturnType_T`. See [this question](http://stackoverflow.com/questions/15148749/pointer-to-class-member-as-a-template-parameter) and [this question](http://stackoverflow.com/questions/5628121/is-it-possible-to-emulate-templateauto-x). – Mankarse Jul 07 '14 at 10:15

0 Answers0