> On 6 Jul 2018, at 11:12, [email protected] wrote:
>
> On 2018/07/05 21:32:25, Dan Eble wrote:
>
>> The rationale is that std::optional is fit for this situation and if
> LilyPond
>> were built with C++17 I would simply have used it.
>
> Any C++17 lookalike package is _not_ "simply using it" but a maintenance
> sink of itself. And a semi-lookalike always requires double-checking in
> what respects it does and does not do the same job. Write code once,
> debug it twice. Not to mention profile it twice.
>
> Reimplementing and then maintaining C++17 features and eventually
> possibly phasing out and replacing them by "the real thing" in 4 years
> or so is not the same as "simply using them".
Use __cplusplus. Later C++ versions also have a 'using' version of typedef,
which I found useful for transforming code.
For example, if you already have introduced your own Optional type:
#if __cplusplus >= 201703L
using Optional = std::optional;
#else
class Optional ...
#endif
and test if it compiles both with and without C++17.
One can do it the other way around, too:
#if __cplusplus < 201703L
namespace std {
using optional = Optional;
}
#endif
and use std::optional, or mix them until all Optional have been removed.
_______________________________________________
lilypond-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-devel