In general one can implement typical type_traits
using template techniques.
However I didn't imagine how std::is_standard_layout
could be implemented in these terms. http://en.cppreference.com/w/cpp/types/is_standard_layout
When I checked the gcc
standard library, I found that it is implemented in terms of __is_standard_layout(T)
which I could not find defined anywhere else. Is this a compiler magic function?
Would it be possible to implement std::is_standard_layout
explicitly?
For example one of the conditions is that it inherits from a single class. That seems to be impossible to determine at compile time.
No, std::is_standard_layout
is not something you can implement without compiler intrinsics. As you've correctly pointed out, it needs more information than the C++ type system can express.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With