aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/target-type.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-01-11 11:02:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-01-11 11:02:16 +0200
commit1d925696ac7eb8d7adb4d70b3f5afb010d745931 (patch)
tree71f5614f431b4097a48ac71211b1f5e6740de765 /libbuild2/target-type.hxx
parent63ea58a2889cd54f32749abf2d10f9a5ea5640ad (diff)
Add ability to alias target type from another project
The syntax is: define <type> = <scope>/<type>
Diffstat (limited to 'libbuild2/target-type.hxx')
-rw-r--r--libbuild2/target-type.hxx8
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>