Skip to content

Remove '=delete' from template methods for Xcode 8 #1133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2020

Conversation

dgobbi
Copy link
Contributor

@dgobbi dgobbi commented Jan 24, 2020

For Apple clang-800.0.42.1, which was released with Xcode 8 in September 2016, the '=delete' on the 'is' and 'as' methods introduced in 53c8e2c causes the following errors for value.h:

inline declaration of 'as<bool>' follows non-inline definition
inline declaration of 'is<bool>' follows non-inline definition

etcetera for the other specializations of 'is' and 'as'.

I understand, of course, that this use of '=delete' serves a purpose: it allows the C++ compiler to detect when a program uses specializations of is() and as() that aren't implemented. However, this patch will be useful (necessary, in fact) for people who build their projects with Xcode 8.

@coveralls
Copy link

coveralls commented Jan 24, 2020

Coverage Status

Coverage remained the same at 93.699% when pulling 8d4eca3 on dgobbi:xcode8-compat into 6317f9a on open-source-parsers:master.

@BillyDonahue
Copy link
Contributor

Is the existing code correct C++ or not?
It's a little complex. A discussion is here:

https://stackoverflow.com/questions/33256589/specialized-template-function-with-deleted-general-case-fails-to-compile-with

Current draft spec includes the proposed language change: https://eel.is/c++draft/temp.expl.spec

If it's correct C++, then this is a toolchain workaround, which is fine, but based on the discussion regarding the 4-year-old XCode8 compatibility, I expected to find #ifdefs around the code changes.

Messing around to find out when clang stopped complaining about specialization of deleted primary function templates.
https://gcc.godbolt.org/z/tF6_gG
Looks like around clang-3.9

If you don't want ifdefs, we could still do what we want, some other way.

@dgobbi
Copy link
Contributor Author

dgobbi commented Jan 24, 2020

Thanks for the response and the insight. I will amend the commit to add ifdefs for clang and Apple clang. My omission of the ifdefs was to check your attachment to this particular use of '=delete'.

@BillyDonahue
Copy link
Contributor

XCode 8 is so old as to be a very special case, so be sure to check the version of XCode in your ifdefs, not just the vendor macros' existence, so that we're giving the same declarations everywhere that isn't old and weird.

For Apple clang-800.0.42.1, which was released with Xcode 8 in
September 2016, the '=delete' on the 'is' and 'as' methods causes
the following errors for value.h:

  inline declaration of 'as<bool>' follows non-inline definition
  inline declaration of 'is<bool>' follows non-inline definition

etcetera for the other specializations of 'is' and 'as'.  The same
problem also occurs for clang-3.8 but not clang-3.9 or later.
@BillyDonahue BillyDonahue self-assigned this Jan 24, 2020
@BillyDonahue
Copy link
Contributor

Looks good to me!

@dgobbi
Copy link
Contributor Author

dgobbi commented Jan 24, 2020

Thanks for the rapid responses!

@baylesj
Copy link
Contributor

baylesj commented Feb 13, 2020

LGTM.

@baylesj baylesj merged commit dc180eb into open-source-parsers:master Feb 13, 2020
@cdunn2001
Copy link
Contributor

Wow. My instinct would have been to tell Xcode 8 users that they have to use an old release, maybe even 0.10.z. But since a user did all the work, fine. It's just that all these ifdefs can get in the way later. This project is barely maintainable as it is.

We could easily re-break Xcode 8 someday. The only things we guarantee are the things we test, which are the TravisCI builds and the AppVeyor builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants