From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 836A03858C62; Tue, 27 Sep 2022 08:28:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 836A03858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664267305; bh=678q4jxIBdSOiIH10qJ7z2q5Zgi7okZO3+3VykN8U0s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=w9UEX4h8h5PNA+1dQFd/eFIbnx8KLXQxguvThkiZPf96tvZDhYNUFwr1ZmiX+d1rE 7yiHHDcenbtBiFL7CxR7jLAVN05JsU5Q0iz9LGTaExa7LTn61Vb23GB+B/kpvFoRdA EyxuuP+CDCIuAkgcAgKImOH48XkMI2b3v2NxI6Bk= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyBsaWJzdGRjKysvMTA3MDQ5XSBlcnJvcjog4oCYc3RkOjpf?= =?UTF-8?B?X2N4eDExOjpiYXNpY19zdHJpbmc8X0NoYXJULCBfVHJhaXRzLCBfQWxsb2M+?= =?UTF-8?B?OjpvcGVyYXRvciBfX3N2X3R5cGUoKSBjb25zdCBbd2l0aCBfQ2hhclQgPSBj?= =?UTF-8?B?aGFyOyBfVHJhaXRzID0gc3RkOjpjaGFyX3RyYWl0czxjaGFyPjsgX0FsbG9j?= =?UTF-8?B?ID0gc3RkOjphbGxvY2F0b3I8Y2hhcj47IF9fc3ZfdHlwZSA9IHN0ZDo6YmFz?= =?UTF-8?B?aWNfc3RyaW5nX3ZpZXc8Y2hhcj5d4oCZIGlzIGluYWNjZXNzaWJsZSB3aXRo?= =?UTF-8?B?aW4gdGhpcyBjb250ZXh0?= Date: Tue, 27 Sep 2022 08:28:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107049 --- Comment #3 from Jonathan Wakely --- (In reply to Jonathan Wakely from comment #2) > template > using If_sv =3D enable_if_t::va= lue>; It works if this is changed to: template using If_sv =3D enable_if_t<__is_convertible(const T&, string_view)>; So the problem is that it fails an access check when the built-in is used outside the class body. But that should be a SFINAE context. Further reduced: template struct bool_constant { static constexpr bool value =3D B; }; template struct is_convertible : public bool_constant<__is_convertible(From, To)> { }; template struct enable_if { }; template<> struct enable_if { using type =3D void; }; template using enable_if_t =3D typename enable_if::type; class Private { operator int() const; public: void f(const Private&); template enable_if_t::value> f(T) { } }; int main() { Private p; p.f(p); } sfinae.cc: In instantiation of 'struct is_convertible': sfinae.cc:23:5: required by substitution of 'template enable_if_t::value> Private::f(T) [with T =3D Privat= e]' sfinae.cc:30:6: required from here sfinae.cc:6:24: error: 'Private::operator int() const' is private within th= is context 6 | : public bool_constant<__is_convertible(From, To)> | ^~~~~~~~~~~~~~~~~~~~~~~~~~ sfinae.cc:16:3: note: declared private here 16 | operator int() const; | ^~~~~~~~=