aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/function.hxx21
-rw-r--r--libbuild2/test/script/regex.test.cxx6
2 files changed, 18 insertions, 9 deletions
diff --git a/libbuild2/function.hxx b/libbuild2/function.hxx
index b745173..47eee5b 100644
--- a/libbuild2/function.hxx
+++ b/libbuild2/function.hxx
@@ -124,8 +124,8 @@ namespace build2
//
function_impl* const impl;
- // Auxiliary data storage. Note that it is assumed to be POD (no
- // destructors, bitwise copy, etc).
+ // Auxiliary data storage. Note that it is expected to be trivially
+ // copyable and destructible.
//
std::aligned_storage<sizeof (void*) * 3>::type data;
static const size_t data_size = sizeof (decltype (data));
@@ -144,14 +144,21 @@ namespace build2
D d)
: function_overload (an, mi, ma, move (ts), im)
{
- // std::is_pod appears to be broken in VC16 and also in GCC up to
- // 5 (pointers to members).
+ static_assert (sizeof (D) <= data_size, "insufficient space for data");
+
+ // These tests appear to be broken in VC16 and also in GCC up to 5 for
+ // pointers to members.
//
-#if !((defined(_MSC_VER) && _MSC_VER < 2000) || \
+#if !((defined(_MSC_VER) && _MSC_VER < 2000) || \
(defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 5))
- static_assert (std::is_pod<D>::value, "type is not POD");
+
+ static_assert (std::is_trivially_copyable<D>::value,
+ "data is not trivially copyable");
+
+ static_assert (std::is_trivially_destructible<D>::value,
+ "data is not trivially destructible");
#endif
- static_assert (sizeof (D) <= data_size, "insufficient space");
+
new (&data) D (move (d));
}
};
diff --git a/libbuild2/test/script/regex.test.cxx b/libbuild2/test/script/regex.test.cxx
index c46068b..5a93c53 100644
--- a/libbuild2/test/script/regex.test.cxx
+++ b/libbuild2/test/script/regex.test.cxx
@@ -2,7 +2,7 @@
// license : MIT; see accompanying LICENSE file
#include <regex>
-#include <type_traits> // is_pod, is_array
+#include <type_traits> // is_*
#include <libbuild2/test/script/regex.hxx>
@@ -23,7 +23,9 @@ main ()
// Test line_char.
//
{
- static_assert (is_pod<lc>::value && !is_array<lc>::value,
+ static_assert (is_trivial<lc>::value &&
+ is_standard_layout<lc>::value &&
+ !is_array<lc>::value,
"line_char must be char-like");
// Zero-initialed line_char should be the null-char as required by