diff options
Diffstat (limited to 'libbuild2/target-type.hxx')
-rw-r--r-- | libbuild2/target-type.hxx | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libbuild2/target-type.hxx b/libbuild2/target-type.hxx index c0a5571..fcf867a 100644 --- a/libbuild2/target-type.hxx +++ b/libbuild2/target-type.hxx @@ -201,18 +201,18 @@ namespace build2 return type_map_.empty (); } - const target_type& + pair<reference_wrapper<const target_type>, bool> insert (const target_type& tt) { - type_map_.emplace (tt.name, target_type_ref (tt)); - return tt; + auto r (type_map_.emplace (tt.name, target_type_ref (tt))); + return {r.second ? tt : r.first->second.get (), r.second}; } template <typename T> const target_type& insert () { - return insert (T::static_type); + return insert (T::static_type).first; } pair<reference_wrapper<const target_type>, bool> |