Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a way to compile-time assert if a variable is a class, struct or a basic type in c++?
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COAs an aside, why do you care whether it is a class or a struct? Anything could be a class or a struct. Actually if you choose not to rely on the default "private:" for class and "public:" for struct, and instead you write them explicitly, you could change all your classes to structs or vice versa without changing the meaning or behaviour of the code at all.
      singulars
    2. COThe reason for this check is that I have a template function that has most of the functionality the same for every type but there's a part that handles polymorphic classes differently than other types. I've solved the problem for checking if a class is polymorphic with a similar test as the one above ( in my case polymorphic classes must have a certain function that I look for in the test ). But that test doesn't compile if the variable given to the function is not a class type so I need to test before that at least if it's a class or not.
      singulars
    3. COI actually haven't tried that test with a structure but it would make things easier for me to dismiss a structure in a previous test as it can't be polymorphic.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload