diff options
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 |