Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Private access in partial specialization definitions

52 views
Skip to first unread message

maowf...@amfoijefa.ca

unread,
Dec 14, 2012, 12:20:41 PM12/14/12
to
GCC's behavior differs from Clang and Visual C++ in the following examples:

#include<type_traits>

template<typename T, typename Enabler = void>
struct test1 : std::false_type {};

template<typename T>
struct test1<T, typename T::typedef_test> : std::true_type {};

template<typename T, typename Enabler = void>
struct test2 : std::false_type {};

template<typename T>
struct test2<T,
typename std::enable_if<
T::enum_test,
void
>::type> : std::true_type {};

struct object
{
template<typename T, typename Enabler>
friend struct test1;

template<typename T, typename Enabler>
friend struct test2;

private:
enum { enum_test = true };
typedef void typedef_test;
};

// test1
static_assert(test1<object>::value, "failed");

// test2
static_assert(test2<object>::value, "failed");

Results (compiler, test1, test2):
g++ (4.7.2), pass, fail
g++ (4.8.0), fail, fail
clang++ (3.3), pass, pass
Visual C++ 2012, pass, pass

Which is correct? I'd appreciate direction to the relevant sections of
the standard if at all possible.


--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp...@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]

Daniel Krügler

unread,
Dec 15, 2012, 1:53:09 PM12/15/12
to
With the resolution of the issue

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#580

the code should be well-formed. It looks to me as if gcc hasn't yet
applied the resolution. I suggest to open a compiler bug for this.

HTH & Greetings from Bremen,

Daniel Kr�gler
0 new messages