C++ Logo

std-proposals

Advanced search

Re: Feature test macro for variant<bool, string> taking const char* fix?

From: Emile Cormier <emile.cormier.jr_at_[hidden]>
Date: Sun, 6 Dec 2020 18:29:25 -0400
I do, Barry. Something like this (not tested):

struct parse_event
{
    template <typename T>
    parse_event(T&& value) : token(std::forward<T>(value)) {}

#ifndef VARIANT_SAFELY_TAKES_CHAR_POINTER
    // Workaround
    parse_event(const char* s) : token(std::string(s)) {}
#endif

    std::variant<bool, int, std::string> token;
};

The idea is to disable the workaround code when the C++ library
implementation has the P0608/P1957 fixes.

On Sun, Dec 6, 2020 at 6:17 PM Barry Revzin <barry.revzin_at_[hidden]> wrote:

> On Sun, Dec 6, 2020 at 3:18 PM Emile Cormier via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> Hi Everyone,
>>
>> Is there a feature test macro for P0608 and P1957, which fix the problem
>> of constructing a variant<bool, string> with a const char*?
>>
>> According to the C++20 draft, the __cpp_­lib_­variant macro is still
>> stuck at 201606L and I cannot find any other macro concerning this.
>>
>> Cheers,
>> Emile Cormier
>>
>
> Do you have an example of code that you would want to write, given such a
> macro?
>
> Barry
>

Received on 2020-12-06 16:29:37