mirror of
https://github.com/boostorg/config.git
synced 2026-08-09 23:11:16 +02:00
Make __builtin_launder test code C++03.
This commit is contained in:
@@ -12,18 +12,21 @@
|
||||
#include <new>
|
||||
|
||||
namespace boost_has_builtin_launder {
|
||||
|
||||
//
|
||||
// This is intensionally C++03 code as __builtin_launder can be used even when std::launder
|
||||
// isn't available (ie pre-C++17).
|
||||
struct X
|
||||
{
|
||||
const int const_int;
|
||||
X() = delete;
|
||||
X() : const_int(0) {};
|
||||
X(const int i) : const_int(i) {}
|
||||
X(const X& o) : const_int(o.const_int) {};
|
||||
};
|
||||
|
||||
int test()
|
||||
{
|
||||
X original{1};
|
||||
new (&original) X{2}; //Overwrite X
|
||||
X original(1);
|
||||
new (&original) X(2); //Overwrite X
|
||||
return __builtin_launder(&original)->const_int == 2 ? 0 : -1; //After laundering, new value should be returned
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user