aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/target.hxx6
1 files changed, 4 insertions, 2 deletions
diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx
index de17fa8..21b5dab 100644
--- a/libbuild2/target.hxx
+++ b/libbuild2/target.hxx
@@ -720,7 +720,8 @@ namespace build2
typename std::enable_if<std::is_trivially_destructible<T>::value,T&>::type
data (R&& d) const
{
- assert (sizeof (T) <= data_size && data_dtor == nullptr);
+ assert (sizeof (T) <= data_size);
+ clear_data ();
return *new (&data_pad) T (forward<R> (d));
}
@@ -730,7 +731,8 @@ namespace build2
typename std::enable_if<!std::is_trivially_destructible<T>::value,T&>::type
data (R&& d) const
{
- assert (sizeof (T) <= data_size && data_dtor == nullptr);
+ assert (sizeof (T) <= data_size);
+ clear_data ();
T& r (*new (&data_pad) T (forward<R> (d)));
data_dtor = [] (void* p) {static_cast<T*> (p)->~T ();};
return r;