Page 1 of 1

Interesting tidbit

Posted: March 8th, 2017, 9:11 am
by MrGodin
Hey i came across this, seems reasonable for type checking in a template

Code: Select all

template<class T>
class shape
{
	const bool IsV_PTN = std::is_same<T, VertexPTN>::value;
	const bool IsV_PT = std::is_same<T, VertexPT>::value;
....
}
Any one using this ?

Re: Interesting tidbit

Posted: March 8th, 2017, 10:38 am
by chili
I've put this into some recent code.

Code: Select all

		static_assert(std::is_same<S,TSelf>::value,"Dispatch handler function must be of same class as target class!");
		static_assert(std::is_base_of<DispatcheeBase,TOther>::value,"Dispatch function param must be derived from DispatcheeBase!");

Re: Interesting tidbit

Posted: March 8th, 2017, 10:59 am
by albinopapa
I've been mucking around with template type traits and trying to find ways of deducing types, thanks for the post. If you find any more useful stuff, please share. I know I could rummage through the STL myself, but multi-threading seems more efficient. :)

Re: Interesting tidbit

Posted: March 8th, 2017, 4:41 pm
by MrGodin
albinopapa wrote:I've been mucking around with template type traits and trying to find ways of deducing types, thanks for the post. If you find any more useful stuff, please share. I know I could rummage through the STL myself, but multi-threading seems more efficient. :)
Hey, no problem. I tried a few different way as well, checking byte size of structure or class , but thats not always reliable.
did this as well

Code: Select all

tempalte<typename T>
class Something
{
public:
T typeDef;
}
@chili,cool, i like the std::is_base_of, i'll definatly use that as well