aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/variable.ixx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/variable.ixx')
-rw-r--r--libbuild2/variable.ixx36
1 files changed, 36 insertions, 0 deletions
diff --git a/libbuild2/variable.ixx b/libbuild2/variable.ixx
index 9b24b9d..fd78842 100644
--- a/libbuild2/variable.ixx
+++ b/libbuild2/variable.ixx
@@ -114,6 +114,22 @@ namespace build2
return *this;
}
+ template <typename T>
+ inline value& value::
+ prepend (T v)
+ {
+ assert (type == &value_traits<T>::value_type || (type == nullptr && null));
+
+ // Prepare the receiving value.
+ //
+ if (type == nullptr)
+ type = &value_traits<T>::value_type;
+
+ value_traits<T>::prepend (*this, move (v));
+ null = false;
+ return *this;
+ }
+
inline value& value::
operator= (names v)
{
@@ -867,6 +883,26 @@ namespace build2
new (&v.data_) map<K, V> (move (x));
}
+ template <typename K, typename V>
+ inline void value_traits<std::map<K, V>>::
+ prepend (value& v, map<K, V>&& x)
+ {
+ if (v)
+ {
+ map<K, V>& m (v.as<map<K, V>> ());
+
+ m.swap (x);
+
+ // Note that this will only move values. Keys (being const) are still
+ // copied.
+ //
+ m.insert (make_move_iterator (x.begin ()),
+ make_move_iterator (x.end ()));
+ }
+ else
+ new (&v.data_) map<K, V> (move (x));
+ }
+
// variable_pool
//
inline const variable& variable_pool::