diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-11-12 12:20:34 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-11-12 12:20:34 +0200 |
commit | c0743592bfae808b61a8146fd97af94b50156f0e (patch) | |
tree | a1d0b98f24391ec1350be23eefe5ef492fa3c387 /libbuild2/variable.hxx | |
parent | 87d871e77649d439b4d62208576239d1341eedef (diff) |
Add support for vector<pair<K, V>> variable values
Diffstat (limited to 'libbuild2/variable.hxx')
-rw-r--r-- | libbuild2/variable.hxx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libbuild2/variable.hxx b/libbuild2/variable.hxx index 6a2c681..3389a8e 100644 --- a/libbuild2/variable.hxx +++ b/libbuild2/variable.hxx @@ -954,6 +954,33 @@ namespace build2 static const value_type_ex value_type; }; + // vector<pair<K, V>> + // + template <typename K, typename V> + struct value_traits<vector<pair<K, V>>> + { + static_assert (sizeof (vector<pair<K, V>>) <= value::size_, + "insufficient space"); + + static void assign (value&, vector<pair<K, V>>&&); + static void append (value&, vector<pair<K, V>>&&); + static void prepend (value& v, vector<pair<K, V>>&& x) { + return append (v, move (x));} + static bool empty (const vector<pair<K, V>>& x) {return x.empty ();} + + static const vector<pair<K, V>> empty_instance; + + // Make sure these are static-initialized together. Failed that VC will + // make sure it's done in the wrong order. + // + struct value_type_ex: build2::value_type + { + string type_name; + value_type_ex (value_type&&); + }; + static const value_type_ex value_type; + }; + // map<K, V> // template <typename K, typename V> @@ -995,6 +1022,9 @@ namespace build2 extern template struct LIBBUILD2_DECEXPORT value_traits<uint64s>; extern template struct LIBBUILD2_DECEXPORT + value_traits<vector<pair<string, string>>>; + + extern template struct LIBBUILD2_DECEXPORT value_traits<std::map<string, string>>; extern template struct LIBBUILD2_DECEXPORT |