On 25.11.2016 11:09, Stefan Ram wrote:
> IIRC, the C++ primer says that a converting constructor is a
> constructor that accepts exactly one argument. It says that
> constructors with more arguments can not possibly be considered
> for conversions, because a conversion situation only is given
> in the case of a single value.
>
> However, we all know 12.3.1p1 (now not from the primer,
> but from a recent draft of the standard):
>
> »A constructor declared without the function-specifier
> explicit specifies a conversion from the types of its
> parameters (if any) to the type of its class. Such a
> constructor is called a converting constructor.« .
>
> So, today's definition of »converting constructor« is not
>
> - one argument
>
> but
>
> - no "explicit".
>
> But after the C++ primer has so convincingly explained why a
> converting constructor is a constructor that accepts a single
> argument, why has the standard dropped this requirement?
>
[code]
struct A
{
A( int, int ) {}
};
struct B
{
explicit B( int, int ) {}
};
auto main() -> int
{
A a = {1, 2};
B b = {1, 2}; //! Nyet, constructor is explicit.
}
[/code]
Cheers & hth.,
- Alf