C++ Logo


Advanced search

Re: [SG10] __has_[cpp_]attribute

From: Stephen Kelly <steveire_at_[hidden]>
Date: Tue, 10 Jun 2014 00:39:57 +0200
Nelson, Clark wrote:

>> > Would it be fair to restate your questions as, why are we
>> recommending
>> > something like __has_attribute when we didn't recommend
>> __has_feature?
> I was actually hoping someone would provide an answer to that question.

Can we ask the person who proposed it?

> I myself am opposed -- weakly -- to the __has_attribute syntax, or some
> variation thereof, for all the reasons we didn't go with __has_feature in
> the first place, as I explained a couple of weeks ago.

I favor consistency between the feature test and the attribute test.

I weakly favor __has_foo() for these reasons:

1) For creating the consistency (at least from the users point of view) of
all such tests now and in the future being __has_foo().

For example, __has_builtin(is_final) might solve the problem here:




2) For making it harder for users to make mistakes such as

#ifdef __cpp_foo

when they meant

#if __cpp_foo


#if __cpp_foo > 201404


#if __cpp_foo >= 201404

I think __cpp_foo is fine because it might be easier to implement. However,
I would request consistent prefixes/namespacing to allow for growth in the
classes of tests recommended (eg builtins):




Received on 2014-06-10 00:40:06