The Partridge Family were neither partridges nor a family. Discuss.
-
MrGodin
- Posts: 721
- Joined: November 30th, 2013, 7:40 pm
- Location: Merville, British Columbia Canada
Post
by MrGodin » March 8th, 2017, 9:11 am
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 ?
Curiosity killed the cat, satisfaction brought him back
-
chili
- Site Admin
- Posts: 3948
- Joined: December 31st, 2011, 4:53 pm
- Location: Japan
-
Contact:
Post
by chili » March 8th, 2017, 10:38 am
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!");
Chili
-
albinopapa
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Post
by albinopapa » March 8th, 2017, 10:59 am
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.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
-
MrGodin
- Posts: 721
- Joined: November 30th, 2013, 7:40 pm
- Location: Merville, British Columbia Canada
Post
by MrGodin » March 8th, 2017, 4:41 pm
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
Curiosity killed the cat, satisfaction brought him back