Boost logo

Boost :

Subject: Re: [boost] [contract] auto_..._error regression tests fail on C++1z
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2017-10-04 06:45:20


2017-09-29 4:29 GMT+02:00 Lorenzo Caminiti via Boost <boost_at_[hidden]>
:

> On Thu, Sep 28, 2017 at 4:05 PM, Niall Douglas via Boost
> <boost_at_[hidden]> wrote:
> >> Why... what changed in C++1z that makes the above compile? How can I
> >> prevent copying x outside its friend function f in C++1z?
> >
> > C++ 17 guarantees copy elision in the strong sense.
> >
> > Note it still can't be copied, but it can be initialised now. So disable
> > non-friend construction to fix.
>
> I see. However, making the constructor private still does not make the
> compilation fail. The following code compiles fine on clang++
> -std=c++1z ...
>
> struct x {
> private:
> x() {}
> x(x const&) {}
> x& operator=(x const&) { return *this; }
>
> friend x f();
> };
>
> x f() { return x(); }
>
> int main() {
> auto xx = f();
> return 0;
> }
>
> Is there any way to make that `auto xx = f()` in main fail at compile
> time in C++1z?
>

But why do you want this program to fail to compile?

Regards,
&rzej;


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk