Skip to content

store_into does not properly handle numeric types #415

@Redbeanw44602

Description

@Redbeanw44602

var = details::parse_number<T, details::radix_10>()(s);

store_into treats all numbers as decimal numbers, which is incorrect.

If we use:

uint64_t foo;

program.add_argument("foo")
    .scan<'x', uint64_t>()
    .store_into(foo);
./foo 0xABCD
!!! std::invalid_argument will be thrown: pattern '0xABCD' does not match to the end

But program.get<uint64_t>() can work properly.


Another observation is that when using get<T>, the parsing only happens once, while store_into happens twice. I think this could be optimized. 🤔

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions