https://bugs.llvm.org/show_bug.cgi?id=40321
Bug ID: 40321
Summary: declaring a template instance as friend makes all
instances of the template as friend
Product: clang
Version: 7.0
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangb...@nondot.org
Reporter: sw6u...@gmail.com
CC: blitzrak...@gmail.com, dgre...@apple.com,
erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
richard-l...@metafoo.co.uk
Created attachment 21329
--> https://bugs.llvm.org/attachment.cgi?id=21329&action=edit
the code
// this code should compile
// because 'Sub' declares only 'Wrapper< Good >' as friend.
template< class ... >
using Void_t = void;
template< class Key >
struct Wrapper
{
template< class To, class From, class Void = void >
struct IsCastable
{ static constexpr bool value = false; };
template< class To, class From >
struct IsCastable<
To, From, Void_t< decltype( static_cast< To >( From{} ) ) >
>
{ static constexpr bool value = true; };
};
struct Good {};
struct Bad {};
struct Base {};
struct Sub : private Base
{
friend struct Wrapper< Good >; // Wrapper< Good > is the only friend
};
int main()
{
// friendly access : should be true
static_assert(
Wrapper< Good >::IsCastable< Base*, Sub* >::value );
// non-friendly access : should be false
static_assert(
!Wrapper< Bad >::IsCastable< Base*, Sub* >::value );
return 0;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs