args icon indicating copy to clipboard operation
args copied to clipboard

add copy constructors and/or move semantics to support modern C++ auto expresions

Open weegreenblobbie opened this issue 7 years ago • 2 comments

I'd love to write this:

    auto parser = args::ArgumentParser(
        "Benchmark a BFS graph search on a knureon complex"
    );

    auto help = args::HelpFlag(
        parser,
        "help",
        "Display this help menu",
        {'h', "help"}
    );

    auto args::ValueFlag<uint32_t>(
        parser,
        "seed",
        "The seed to initialize the random number generator",
        {"seed"}
    );

    auto scale = args::ValueFlag<uint32_t>(
        parser,
        "scale",
        "The logarithm base two of the number of vertices",
        {'s', "scale"}
    );

    auto edgefactor = args::ValueFlag<uint32_t>(
        parser,
        "edgefactor",
        "The ratio of the graph’s edge count to its vertex count",
        {'e', "edgefactor"}
    );

as I find it easier to read and encourages the use of auto everywhere.

weegreenblobbie avatar Nov 30 '17 23:11 weegreenblobbie

I agree entirely (at the very least, it should be available). This should be doable without breaking BC. I think it probably makes more sense to have the factories live on the parser, though, more like

auto parser = args::ArgumentParser(
    "Benchmark a BFS graph search on a knureon complex"
);

auto help = parser.HelpFlag(
    "help",
    "Display this help menu",
    {'h', "help"}
);

auto seed = parser.ValueFlag<uint32_t>(
    "seed",
    "The seed to initialize the random number generator",
    {"seed"}
);

Taywee avatar Nov 30 '17 23:11 Taywee

Nice!

weegreenblobbie avatar Nov 30 '17 23:11 weegreenblobbie