A C++ question: when to use "friend class"/"friend template"

Mojca Miklavec mojca at macports.org
Thu Sep 19 01:00:08 PDT 2013


On Tue, Aug 20, 2013 at 12:38 AM, Mojca Miklavec wrote:
> On Sun, Aug 18, 2013 at 10:45 AM, Joshua Root wrote:
>> On 2013-8-18 16:55 , Mojca Miklavec wrote:
>>>
>>> When trying to upgrade a port (hugin-app in particular) I had to
>>> modify the following code:
>>>
>>>  #ifdef __GNUC__
>>>  friend class Notify::self_type;
>>>  #else
>>>  friend typename Notify::self_type;
>>>  #endif
>>>
>>> The Clang compiler (Xcode Xcode 4.6.3 on Lion) failed to work with
>>> "friend class Notify::self_type;". As a temporary patch I removed
>>> #ifdef and made the compiler always end up seeing the code "friend
>>> typename Notify::self_type;", but I believe that this will break the
>>> gcc compilers (I didn't try though because compilation takes forever).
>
> Here is the context:
>     http://sourceforge.net/p/hugin/hugin/ci/default/tree/src/foreign/vigra/vigra/cachedfileimage.hxx
>
>> But AIUI 'friend typename' is not valid in standards prior to
>> C++11.
>
> So is there any
>     #ifdef __CXX11
> ? ;)

Answering myself (after fiddling with another ticket):
    #if __cplusplus >= 201103L

Mojca


More information about the macports-dev mailing list