integral vs. user-defined type check

M

maynard

Is there a way to check if an object is an instance of a user-defined
type or an integral type? I have a templated class that this would be
very handy in (do _something_ if the template parameter is integral
type, or call a method of the template parameter if it is a
user-defined type/class).

I know this is quite error prone (e.g., instantiating the template
class with a class that doesn't define the required method), but this
is just for internal use (nothing distributed or production level).

Thanks in advance.
 
V

Victor Bazarov

maynard said:
Is there a way to check if an object is an instance of a user-defined
type or an integral type? I have a templated class that this would be
very handy in (do _something_ if the template parameter is integral
type, or call a method of the template parameter if it is a
user-defined type/class).

I know this is quite error prone (e.g., instantiating the template
class with a class that doesn't define the required method), but this
is just for internal use (nothing distributed or production level).

Specialise. Explicitly.

See 'has_member' in archives.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top