A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/CLIUtils/CLI11/issues/566 below:

unable to customize parse function for double_constructible types in C++20. · Issue #566 · CLIUtils/CLI11 · GitHub

Consider following code:
All works fine with C++14 & C++17.
But failed to call my function in C++20.

Tested under Visual Studio 16.9.0 with "/std:c++latest".

#include <CLI/App.hpp>
#include <CLI/CLI.hpp>
#include <iostream>
#include <sstream>


template <class T = int>
struct Values
{
    T a;
    T b;
    T c;
};

using DoubleValues = Values<double>;


namespace CLI
{
auto &&operator>>(std::istringstream &in, Values<double> &v)
{
    std::string input;
    in >> input;
    std::cout
        << "called correct function " __FUNCTION__ " ! "
                                                   "val: "
        << input << std::endl;
    return in;
}
bool lexical_cast(const std::string &input,
                  Values<double> &v)
{
    std::cout
        << "called correct function " __FUNCTION__ " ! "
                                                   "val: "
        << input << std::endl;
    return true;
}

};// namespace CLI

DoubleValues doubles;
void argparse(CLI::Option_group *group)
{
    group->add_option("--fee-rate", doubles)
        ->envname("FEE_RATE")
        ->default_str("0");
}

int main(int argc, char **argv)
{
    CLI::App app;

    argparse(app.add_option_group("param"));
    CLI11_PARSE(app, argc, argv);
    return 0;
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4