From b86c1d8d2e0be140f6854d869e07139ff3c4221c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 24 Aug 2020 10:51:26 +0200 Subject: Add copying version of convert(value) --- libbuild2/variable.ixx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'libbuild2/variable.ixx') diff --git a/libbuild2/variable.ixx b/libbuild2/variable.ixx index a11ee12..c8f9541 100644 --- a/libbuild2/variable.ixx +++ b/libbuild2/variable.ixx @@ -7,6 +7,19 @@ namespace build2 { + // value_type + // + template + inline const value_type* value_type:: + is_a () const + { + const value_type* b (this); + for (; + b != nullptr && b != &value_traits::value_type; + b = b->base_type) ; + return b; + } + // value // inline bool value:: @@ -169,10 +182,7 @@ namespace build2 // // Note that here we use the value type address as type identity. // - const value_type* b (v.type); - for (; - b != nullptr && b != &value_traits::value_type; - b = b->base_type) ; + const value_type* b (v.type->is_a ()); assert (b != nullptr); return *static_cast (v.type->cast == nullptr -- cgit v1.1