[type_traits] is_empty fails on final classes.
Hi.
It seems boost::is_empty uses Empty Base Optimisation to detect whether a
class type is stateless or not. This predictably fails on final types, as
they cannot be inherited from:
#include <iostream>
#include
On 22 December 2013 13:53, yuri kilochek wrote:
Now, is it at all possible to implement conforming is_empty without resorting to compiler magic that are intrinsics?
No, I don't think it's possible. On the plus side, any compiler that supports the 'final' keyword must provide some sort of intrinsic for its own std::lib, so Boost can use the relevant intrinsic for each such compiler.
22.12.2013 20:38, Jonathan Wakely пишет:
Now, is it at all possible to implement conforming is_empty without resorting to compiler magic that are intrinsics?
No, I don't think it's possible. On the plus side, any compiler that supports the 'final' keyword must provide some sort of intrinsic for its own std::lib, so Boost can use the relevant intrinsic for each such compiler.
Why not to use std::is_empty for all of them? -- Best regards, Sergey Cheban
participants (3)
-
Jonathan Wakely
-
Sergey Cheban
-
yuri kilochek