mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Interop support for initialization via std::initializer_list. (#6672)
Add a new builtin function `cpp.std.initializer_list.make` that takes an array and returns a `std::initializer_list`, initialized to refer to that array. When C++ initialization wants to perform a `std::initializer_list`-from-array construction, synthesize a declaration of a matching builtin function and use that to perform the initialization. Ideally we would specify this conversion as an impl of `ImplicitAs` in the prelude instead of hardcoding it in the interop layer, but unfortunately that's not currently possible, for various reasons -- we can't make the conversion form-generic, we can't deduce the array length from the initializer, and we can't deduce against the arguments of imported C++ class templates yet -- so for now synthesizing a builtin function on demand is the best we can do. Assisted-by: Gemini 3 Pro via Antigravity
This commit is contained in:
@@ -240,6 +240,11 @@ auto GetFacetType(Context& context, const SemIR::FacetTypeInfo& info)
|
||||
context.facet_types().Add(info));
|
||||
}
|
||||
|
||||
auto GetFacetAccessType(Context& context, SemIR::InstId facet_value_inst_id)
|
||||
-> SemIR::TypeId {
|
||||
return GetTypeImpl<SemIR::FacetAccessType>(context, facet_value_inst_id);
|
||||
}
|
||||
|
||||
auto GetPointerType(Context& context, SemIR::TypeInstId pointee_type_id)
|
||||
-> SemIR::TypeId {
|
||||
return GetCompleteTypeImpl<SemIR::PointerType>(context, pointee_type_id);
|
||||
|
||||
Reference in New Issue
Block a user