Hello,
I would like to ask what is wrong with the following code:
```
#include
struct S
{
S& operator=(S&) { return *this; };
};
void thisWillNotCompileInClang()
{
std::optional a;
}
```
Compilation command is `g++ or clang++ -std=c++17 -c source.cpp`. It
compiles without problems wit
> On Nov 5, 2020, at 6:34 AM, Pavel Černohorský via cfe-users
> wrote:
>
> Hello,
>
> I would like to ask what is wrong with the following code:
> ```
>
> #include
>
> struct S
> {
> S& operator=(S&) { return *this; };
> };
>
> void thisWillNotCompileInClang()
> {
> std::optional a;
> }
On 05. 11. 20 15:47, Marshall Clow via cfe-users wrote:
I tried this code on compiler explorer.
It compiles w/o error with clang + libc++
It fails to compile with clang and libstdc++
The error message given is:
In file included from :1:
/opt/compiler-explorer/gcc-10.2.0/lib/gcc/x86_64-linux-gnu
On Thu, Nov 5, 2020 at 11:06 connor horman wrote:
> Looking at https://eel.is/c++draft/optional.optional and optional.assign,
> it shouldn't be ill-formed to have a non copy-constructible type, the copy
> constructor of optional should be defined as deleted.
> [optional.optional.general] clause 3
I've actually reduced the problem to the defaulted copy assignment operator
itself:
gcc: https://godbolt.org/z/83Gjdb
clang: https://godbolt.org/z/z35x4K
The controlling clause would seem to be
https://eel.is/c++draft/class.copy.assign#7.4. In particular, because
overload resolution cannot find th
On Nov 5, 2020, at 6:34 AM, Pavel Černohorský via cfe-users
wrote:
>
> Hello,
>
> I would like to ask what is wrong with the following code:
> ```
>
> #include
>
> struct S
> {
>S& operator=(S&) { return *this; };
> };
>
> void thisWillNotCompileInClang()
> {
> std::optional a;
> }
>