•      Sign In
• Create Account

### #Actualroadysix

Posted 01 September 2012 - 04:34 PM

Ok, I guess the overload is my best bet for now seeing as the explicit specialization doesn't work, thanks Brother Bob, you learn something new everyday haha

EDIT: I have a question about not being able to partially specialize a function as this is news to me.
lets say that I have a template function that takes any type performs some operations and then returns, pretty basic stuff

template <typename T> void function(const T x) { /* ... */ }


Then I would like to "partially specialize" this function for pointers to T, I tried to create an overload like this:

template <typename T> void function(const T* x) { /* ... */ }


I have never had to do anything like this before but that is besides the point. While this compiles, I did not get the expected result
and only the first template function was being called, even when I passed a pointer to the function! Which to me is surprising.

Without being able to partially specialize a function, what would be the correct way to go about setting up something like this?

Thanks

### #3roadysix

Posted 01 September 2012 - 04:24 PM

Ok, I guess the overload is my best bet for now seeing as the explicit specialization doesn't work, thanks Brother Bob, you learn something new everyday haha

EDIT: I have a question about not being able to partially specialize a function as this is news to me.
lets say that I have a template function that takes any type performs some operations and then returns, pretty basic stuff

template <typename T> void function(const T x) { /* ... */ }


Then I would like to "partially specialize" this function for pointers to T, I tried to create an overload like this:

template <typename T> void function(const T* x) { /* ... */ }


I have never had to do anything like this before but that is besides the point. While this compiles, I did not get the expected result
and only the first template function was being called, even when I passed a pointer to the function! Which to me is surprising.

Without being able to partially specialize a function, what would be the correct way to go about setting up something like this?

Thanks
Had I needed something like the above

### #2roadysix

Posted 01 September 2012 - 04:12 PM

Ok, I guess the overload is my best bet for now seeing as the explicit specialization doesn't work, thanks Brother Bob, you learn something new everyday haha

EDIT: I have a question about not being able to partially specialize a function as this is news to me.
lets say that I have a template function that takes any time performs some operations and then returns, pretty basic stuff

template <typename T> void function(const T x) { /* ... */ }


Then I would like to "partially specialize" this function for pointers to T, I tried to create an overload like this:

template <typename T> void function(const T* x) { /* ... */ }


I have never had to do anything like this before but that is besides the point. While this compiles, I did not get the expected result
and only the first template function was being called, even when I passed a pointer to the function! Which to me is surprising.

Without being able to partially specialize a function, what would be the correct way to go about setting up something like this?

Thanks
Had I needed something like the above

### #1roadysix

Posted 01 September 2012 - 03:15 PM

Ok, I guess the overload is my best bet for now seeing as the explicit specialization doesn't work, thanks Brother Bob, you learn something new everyday haha

PARTNERS