diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2020-08-24 10:51:26 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-08-24 10:51:26 +0200 |
commit | b86c1d8d2e0be140f6854d869e07139ff3c4221c (patch) | |
tree | 02b38914484afb6c2a69d041cf026f1d377220bf /libbuild2/variable.ixx | |
parent | b2df0b0663d0537dd3b4f2d28d145ccd90417cab (diff) |
Add copying version of convert<T>(value)
Diffstat (limited to 'libbuild2/variable.ixx')
-rw-r--r-- | libbuild2/variable.ixx | 18 |
1 files changed, 14 insertions, 4 deletions
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 <typename T> + inline const value_type* value_type:: + is_a () const + { + const value_type* b (this); + for (; + b != nullptr && b != &value_traits<T>::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<T>::value_type; - b = b->base_type) ; + const value_type* b (v.type->is_a<T> ()); assert (b != nullptr); return *static_cast<const T*> (v.type->cast == nullptr |