From e649f2d988ce4e7a67aee1236850eb0b95a97d56 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 14 Dec 2015 10:12:23 +0200 Subject: Add support for variable prepend operator: =+ --- build/variable.cxx | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'build/variable.cxx') diff --git a/build/variable.cxx b/build/variable.cxx index 4386c6a..6e02816 100644 --- a/build/variable.cxx +++ b/build/variable.cxx @@ -57,6 +57,14 @@ namespace build return *this; } + value& value:: + prepend (value v, const variable& var) + { + assert (type == v.type); + prepend (move (v.data_), var); + return *this; + } + void value:: append (names v, const variable& var) { @@ -84,6 +92,37 @@ namespace build : state_type::empty; } + void value:: + prepend (names v, const variable& var) + { + // Reduce to append. + // + if (!null () && type != nullptr && type->append != nullptr) + { + state_ = type->append (v, move (data_), var) + ? state_type::filled + : state_type::empty; + swap (data_, v); + return; + } + + if (data_.empty ()) + data_ = move (v); + else + { + v.insert (v.end (), + make_move_iterator (data_.begin ()), + make_move_iterator (data_.end ())); + swap (data_, v); + } + + state_ = (type != nullptr && type->assign != nullptr + ? type->assign (data_, var) + : !data_.empty ()) + ? state_type::filled + : state_type::empty; + } + // bool value // bool value_traits:: -- cgit v1.1