From 9f5c4c1ae3bff517eefb39130287016514fb31c7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 6 Jan 2017 17:28:45 +0200 Subject: Store platform targets as typed target_triplet --- build2/variable | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'build2/variable') diff --git a/build2/variable b/build2/variable index fbb7343..047dc04 100644 --- a/build2/variable +++ b/build2/variable @@ -226,14 +226,13 @@ namespace build2 return reinterpret_cast (data_);} public: - // The maximum size we can store directly in the value is that of names - // (which is a small_vector), which is sufficient for the most + // The maximum size we can store directly is sufficient for the most // commonly used types (string, vector, map) on all the platforms that we // support (each type should static assert this in its value_traits // specialization below). Types that don't fit will have to be handled // with an extra dynamic allocation. // - std::aligned_storage::type data_; + std::aligned_storage::type data_; // VC14 needs decltype. // @@ -666,7 +665,8 @@ namespace build2 template <> struct value_traits { - static_assert (sizeof (process_path) <= value::size_, "insufficient space"); + static_assert (sizeof (process_path) <= value::size_, + "insufficient space"); // This one is represented as a @-pair of names. As a result it cannot // be stored in a container. @@ -681,6 +681,27 @@ namespace build2 static const build2::value_type value_type; }; + + // target_triplet + // + template <> + struct value_traits + { + static_assert (sizeof (target_triplet) <= value::size_, + "insufficient space"); + + static target_triplet convert (name&&, name*); + static void assign (value&, target_triplet&&); + static name reverse (const target_triplet& x) {return name (x.string ());} + static int compare (const target_triplet& x, const target_triplet& y) { + return x.compare (y);} + static bool empty (const target_triplet& x) {return x.empty ();} + + static const bool empty_value = true; + static const char* const type_name; + static const build2::value_type value_type; + }; + // vector // template -- cgit v1.1