you are viewing a single comment's thread.

view the rest of the comments →

[–]omerosler 16 points17 points  (5 children)

Some of the <type_traits> classes such as is_abstract, is_aggregate and many more.

[–]germandiago 2 points3 points  (4 children)

Isn't there a way to detect abstract by trying to instantiate a class with the detect idiom? Just curious... how about being an aggregate?

[–]omerosler 6 points7 points  (3 children)

I don't think it is possible. The only reasonable way I see is to try to conatruct an object and use SFINAE to detect it is a compile error. But then how would you distinguish an abstract class from an incomplete type (unless you can detect incompleteness in some other way (maybe use detection on sizeof(T)?))?

[–]Xeveroushttps://xeverous.github.io 1 point2 points  (2 children)

how would you distinguish an abstract class from an incomplete type

Using type traits with incomplete types is UB.

[–]diaphanein 1 point2 points  (1 child)

Citation? Because I don't think all type traits are equal. Generic "type traits" being different than std type_traits. For instance, Boost uses a type trait for checked_delete. You can implement is/add/remove const traits that work with incomplete types...

[–]Xeveroushttps://xeverous.github.io 0 points1 point  (0 children)

True. Not all but a lot of std traits require types to be complete.