[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

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Sep 27 08:33:20 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107049

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
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)>
{ };

class Private
{
  operator int() const;
};

static_assert( not is_convertible<Private, int>::value, "" );


sfinae.cc: In instantiation of 'struct is_convertible<Private, int>':
sfinae.cc:14:48:   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:11:3: note: declared private here
   11 |   operator int() const;
      |   ^~~~~~~~
sfinae.cc:14:16: error: static assertion failed
   14 | static_assert( not is_convertible<Private, int>::value, "" );
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


More information about the Gcc-bugs mailing list