Given the following
#include <array>
struct litmus final : std::array<unsigned char, 16>
{
};
static_assert(std::is_pod<std::array<unsigned char, 16> >::value, "not pod");
// this fails on MSVC:
static_assert(std::is_pod<litmus>::value, "not pod");
The following compilers agree that litmus
is pod:
However, MSVC12 (VS2013 RTM) maintains that the second assert fails.
EDIT For information:
is_trivially_copyable<litmus>
returns true-ness on MSVC. This might be useful for many cases where actual POD-ness isn't strictly required.
GCC and Clang; that class is POD.
That depends on what exactly you mean with "make MSVC treat the class as pod." If you mean the compiler internals, then no. However, you can (in practice) specialise the trait for litmus
:
namespace std {
template <>
struct is_pod<litmus> : std::true_type
{};
}
Note that going strictly by the standard, this gives undefined behaviour (thanks @R.MartinhoFernandes for pointing this out). However, as a compiler-specific workaround, I'd expect it to work. Use without any warranty.
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