Fred Finkle
Fred Finkle

Reputation: 2017

Turning off static type checking in c++ for a particular method call

I'm using class templates. I have a method that checks to see if it's argument type is a fundamental type (like "int") or an instance of an object (using typeid). If it is an object I want to call a method on that instance. My problem is that the compiler complains when the type variable is bound to "int".

Is there a way to force the check to be performed at run-time??

I'm using g++ on OS X Lion.

Thanks in advance.

Upvotes: 1

Views: 135

Answers (1)

Puppy
Puppy

Reputation: 147036

You need to use a template specialization to achieve this, not typeid. SFINAE can help you write one for all fundamental types faster, I believe.

Upvotes: 2

Related Questions