Bonita Montero writes:
#include <iostream>
#include <atomic>
using namespace std;
int main()
{
struct S { int x; };
constexpr bool SUBST = sizeof(S) == sizeof(atomic<S>);
conditional_t<SUBST, atomic<S>, char> as;
if constexpr( !SUBST )
as = 123;
}
as is tried to compiled although SUBST is false.
Because SUBST is false, as is a
std::atomic<S>
Therefore for
as = 123;
to compile there must be a suitable operator= overload defined. There is
none. std::atomic will supply an operator= that will take a const S & as a parameter, so
as = S{123};
will compile. However, a plain, unadorned 123 will require two implicit conversions to arrive to its happy place, but only one implicit conversion
is allowed, of course.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)