aboutsummaryrefslogtreecommitdiff
path: root/build2/variable.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-08-23 09:05:54 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-08-23 09:05:54 +0200
commitbd32ea47fd8f720b54f81a769dc007d1fdb4e5c1 (patch)
treeefd3aec2fd1e2fd65b0262470de5a2e82d9c8449 /build2/variable.txx
parentce030e8bf6a8f278eb3a571aef0f0df18875daa7 (diff)
Reverse empty simple values as an empty names sequence rather than empty name
This way we get: config.import.foo = Rather than: config.import.foo = {}
Diffstat (limited to 'build2/variable.txx')
-rw-r--r--build2/variable.txx16
1 files changed, 15 insertions, 1 deletions
diff --git a/build2/variable.txx b/build2/variable.txx
index f1335b4..95e4f0a 100644
--- a/build2/variable.txx
+++ b/build2/variable.txx
@@ -148,7 +148,21 @@ namespace build2
names_view
simple_reverse (const value& v, names& s)
{
- s.emplace_back (value_traits<T>::reverse (v.as<T> ()));
+ const T& x (v.as<T> ());
+
+ // Represent an empty simple value as empty name sequence rather than
+ // a single empty name. This way, for example, during serialization we
+ // end up with a much saner looking:
+ //
+ // config.import.foo =
+ //
+ // Rather than:
+ //
+ // config.import.foo = {}
+ //
+ if (!value_traits<T>::empty (x))
+ s.emplace_back (value_traits<T>::reverse (x));
+
return s;
}