The following does not compile due to the static assert failing:
class Ambiguous
{
private:
int i;
public:
constexpr Ambiguous(int _i) : i(_i) {}
};
struct ContainsAmbiguous
{
float a;
float b;
Ambiguous ambiguous;
};
static_assert(vir::struct_size_v<ContainsAmbiguous> != 0);
To see what's wrong I tried reproducing the contents of requires clauses in vir::detail::brace_constructible_impl:
inline auto testinstance = ContainsAmbiguous{
{vir::detail::anything_but_base_of<ContainsAmbiguous>{}},
{vir::detail::anything_but_base_of<ContainsAmbiguous>{}},
{vir::detail::anything_but_base_of<ContainsAmbiguous>{}}, // call to constructor of "Ambiguous" is ambiguous
};
Whereas this compiles:
inline auto testinstance = ContainsAmbiguous{
vir::detail::anything_but_base_of<ContainsAmbiguous>{},
vir::detail::anything_but_base_of<ContainsAmbiguous>{},
vir::detail::anything_but_base_of<ContainsAmbiguous>{},
};
That's a recreation of this clause from brace_constructible_impl:
requires { T{{((void)Indexes, anything_but_base_of<T>())}...}; }
The additional curly braces being added in c1e9325ca880b908746f0c17c02df379889faa6d.
So it seems like although the additional braces prevent confusion due to brace elision they also opt into explicit constructors of the member variables which introduces ambiguity. Not sure what the correct approach here is, if there's a way to make both work at once.
The following does not compile due to the static assert failing:
To see what's wrong I tried reproducing the contents of
requiresclauses invir::detail::brace_constructible_impl:Whereas this compiles:
That's a recreation of this clause from
brace_constructible_impl:The additional curly braces being added in c1e9325ca880b908746f0c17c02df379889faa6d.
So it seems like although the additional braces prevent confusion due to brace elision they also opt into explicit constructors of the member variables which introduces ambiguity. Not sure what the correct approach here is, if there's a way to make both work at once.