Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #567

Private access in partial specialization definitions

From maowfijwef@amfoijefa.ca
Newsgroups comp.std.c++
Subject Private access in partial specialization definitions
Date 2012-12-14 09:20 -0800
Organization unknown
Message-ID <2a114d05-b6ad-4e19-9e0b-050a795f3a63@googlegroups.com> (permalink)

Show all headers | View raw


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-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]

Back to comp.std.c++ | Previous | NextNext in thread | Find similar


Thread

Private access in partial specialization definitions maowfijwef@amfoijefa.ca - 2012-12-14 09:20 -0800
  Re: Private access in partial specialization definitions Daniel Krügler <daniel.kruegler@googlemail.com> - 2012-12-15 10:53 -0800

csiph-web