tcbrindle / NanoRange

Range-based goodness for C++17
Boost Software License 1.0
358 stars 28 forks source link

Support for the Concepts TS #74

Open h-2 opened 5 years ago

h-2 commented 5 years ago

Do you plan to support C++20 concepts and possibly also the Concepts TS? I guess redefining NANO_CONCEPT as concept / concept bool is not sufficient as you need to make sure the subsumption rules work, as well...

Thanks!

tcbrindle commented 5 years ago

Hi @h-2, thanks for your interest in NanoRange!

The very short answer to your question is that no, I don't plan to add any support for language concepts at this time.

The longer answer is that, as you correctly point out, properly supporting concepts is not just a simple matter of redefining the NANO_CONCEPT macro -- not only do you need to deal with the subsumption rules, but you probably also want to use requires rather than std::enable_if when constraining things.

Range-V3 trunk handles this using a lot of preprocessor magic, which in principle we could adopt for NanoRange too (under the Boost licence). However, I'm reluctant to do so, because:

The other thing to mention is that unlike Range-V3 (which has tons of views and actions which have not yet been proposed for the standard), NanoRange intentionally only provides what will be in C++20 (that's the "nano" part, for large values of "nano"!). By the time we have conforming C++20 compilers, I'm hopeful that their standard libraries will also come with implementations of std::ranges, making NanoRange basically redundant there.

I hope this answers your question, even if it's not the answer you might have been hoping for. If you have any more questions about NanoRange, please let me know :-).

eigenwhat commented 5 years ago

The concepts emulation and metaprogramming magic is probably a major contributor to why C++17 "conformant" MSVC prior to VS2019 can't compile C++14 library range-v3 at all, and even then the 2019 compiler can only do so with some special switches, including the still experimental C99 preprocessor. Whinging aside, it'd likely have a negative effect on this library's platform compatibility.

tcbrindle commented 5 years ago

even then the 2019 compiler can only do so with some special switches

In fairness, NanoRange also requires the permissive- special switch in order to work on MSVC.