Overloading C++ Template functions without copying code
<p>I wrote the following function:</p>

<pre><code>template&lt; class C, typename T, typename U &gt;
void addVarCB(C * _this, const std::string &amp;name, 
    T(C::*getter)(void) const, U(C::*setter)(const T&amp;), const std::string &amp;def);
</code></pre>

<p>Then I realized that it wont work if setter takes a T as input, so I overloaded the function:</p>

<pre><code>template&lt; class C, typename T, typename U &gt;
void addVarCB(C * _this, const std::string &amp;name, 
T(C::*getter)(void) const, U(C::*setter)(T), const std::string &amp;def = "");
</code></pre>

<p>And now I am realizing that even this will fail if the getter returns</p>

<pre><code>const T &amp;
T &amp;
const T *
T *
const T // yeah this is dumb but someone on my team wrote code like this...
</code></pre>

<p>Am I doomed to copying the same code all over the place?
Hopefully at least solution just for the reference versions?</p>

<p>Note that the function takes a this pointer to an object, a getter and a setter public member functions.
The function will then interface with a GUI allowing the getter and setter to be called back later.</p>
