Date: Sun, 6 Dec 2020 16:34:02 -0600
On Sun, Dec 6, 2020 at 4:29 PM Emile Cormier <emile.cormier.jr_at_[hidden]>
wrote:
> 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.
>
You could just write:
struct parse_event
{
template <typename T>
parse_event(T&& value) : token(std::forward<T>(value)) {}
// Workaround
parse_event(const char* s) : token(std::string(s)) {}
std::variant<bool, int, std::string> token;
};
This works regardless of whether the fix is implemented.
Barry
wrote:
> 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.
>
You could just write:
struct parse_event
{
template <typename T>
parse_event(T&& value) : token(std::forward<T>(value)) {}
// Workaround
parse_event(const char* s) : token(std::string(s)) {}
std::variant<bool, int, std::string> token;
};
This works regardless of whether the fix is implemented.
Barry
Received on 2020-12-06 16:34:17