public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/107049] error: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator __sv_type() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; __sv_type = std::basic_string_view<char>]’ is inaccessible within this context
Date: Tue, 27 Sep 2022 08:28:25 +0000 [thread overview]
Message-ID: <bug-107049-4-BnKUEraGNK@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107049-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107049
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #2)
> template<class T>
> using If_sv = enable_if_t<is_convertible<const T&, string_view>::value>;
It works if this is changed to:
template<class T>
using If_sv = 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<bool B>
struct bool_constant { static constexpr bool value = B; };
template<typename From, typename To>
struct is_convertible
: public bool_constant<__is_convertible(From, To)>
{ };
template<bool> struct enable_if { };
template<> struct enable_if<true> { using type = void; };
template<bool B> using enable_if_t = typename enable_if<B>::type;
class Private
{
operator int() const;
public:
void f(const Private&);
template<class T>
enable_if_t<is_convertible<T, int>::value>
f(T)
{ }
};
int main()
{
Private p;
p.f(p);
}
sfinae.cc: In instantiation of 'struct is_convertible<Private, int>':
sfinae.cc:23:5: required by substitution of 'template<class T>
enable_if_t<is_convertible<T, int>::value> Private::f(T) [with T = Private]'
sfinae.cc:30:6: required from here
sfinae.cc:6:24: error: 'Private::operator int() const' is private within this
context
6 | : public bool_constant<__is_convertible(From, To)>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
sfinae.cc:16:3: note: declared private here
16 | operator int() const;
| ^~~~~~~~
next prev parent reply other threads:[~2022-09-27 8:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-27 7:54 [Bug libstdc++/107049] New: " marxin at gcc dot gnu.org
2022-09-27 7:55 ` [Bug libstdc++/107049] " marxin at gcc dot gnu.org
2022-09-27 7:56 ` marxin at gcc dot gnu.org
2022-09-27 8:20 ` redi at gcc dot gnu.org
2022-09-27 8:28 ` redi at gcc dot gnu.org [this message]
2022-09-27 8:33 ` redi at gcc dot gnu.org
2022-09-27 8:41 ` [Bug c++/107049] " redi at gcc dot gnu.org
2022-09-27 10:35 ` redi at gcc dot gnu.org
2022-09-27 13:00 ` cvs-commit at gcc dot gnu.org
2022-09-27 13:01 ` redi at gcc dot gnu.org
2022-09-27 14:19 ` ville.voutilainen at gmail dot com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-107049-4-BnKUEraGNK@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).