geodynamics / aspect

A parallel, extensible finite element code to simulate convection in both 2D and 3D models.
https://aspect.geodynamics.org/
Other
217 stars 232 forks source link

string_to_unsigned_int #5835

Closed tjhei closed 4 weeks ago

tjhei commented 1 month ago

required for #5748

tjhei commented 1 month ago

Why can't you just use string_to_int and check that the result is nonnegative?

Do you mean like this? Or do you mean I should just do this wherever I need to parse unsigned ints?

bangerth commented 1 month ago

Yes, something like this, but I was really just thinking of using string_to_int everywhere. You probably use this for reading parameters, where the ParameterHandler has already checked that the numbers you're parsing are non-negative.

tjhei commented 1 month ago

has already checked that the numbers you're parsing are non-negative.

Yes. Except I then have to somehow convert a std::vector<int> to std::vector<unsigned int> to store it (for example compositional degrees).