Skip to content

handling types #3

@peterritter

Description

@peterritter

Hi josua
I've just started to test your API. Are you receptive to new ideas? If not it's ok, just ignore me. But if you are, here are some ideas:

(1)

O.get().u32

I don't really like the look of the above. Why not simply allows access like this:

O.get<unsigned>()
O.get<double>()
O.get<std::string>()

You have defined a bunch of types yourself, but they pretty much map straight back to c++ types. Why not use the C++ types directly? Use your own types internally only. If the conversion fails, throw an exception. Maybe even better:

if(parser.available("optimization")){
        int o = parser.get<int>("optimization");
}

I think it worth thinking about this. I'm sure its not entirely straight forward, especially in light of interpreting empty string values/ 'null-strings'. I had many such situations in my own code recently, and I usually found that a simple solution was usually possible. I'm happy to discuss.

(2)
Also, personally I don't like the:

auto&& O = parser["optimization"];

I'm not even sure what the auto&& is really for. Is a simple reference not enough?

Thanks, Peter

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions