Skip to content

Add numeric conversions #26

@unterumarmung

Description

@unterumarmung

Suggested API:

    // numeric conversions
    template <size_t N>
    constexpr int stoi(const fixed_string<N>& str, int base = 10);
    
    template <size_t N>
    constexpr unsigned stou(const fixed_string<N>& str, int base = 10);
    
    template <size_t N>
    constexpr long stol(const fixed_string<N>& str, int base = 10);
    
    template <size_t N>
    constexpr unsigned long stoul(const fixed_string<N>& str, int base = 10);
    
    template <size_t N>
    constexpr long long stoll(const fixed_string<N>& str, int base = 10);
    
    template <size_t N>
    constexpr unsigned long long stoull(const fixed_string<N>& str, int base = 10);
    
    template <size_t N>
    constexpr float stof(const fixed_string<N>& str);
    
    template <size_t N>
    constexpr double stod(const fixed_string<N>& str);
    
    template <size_t N>
    constexpr long double stold(const fixed_string<N>& str);
    
    template <auto val> // where decltype(val) is an integral type but not any of char types
    constexpr fixed_string</*...*/> to_fixed_string() noexcept;

Proposed implementation: using to_chars and from_chars from <charconv>
Known issues: cannot be really constexpr

  • Create implementation
  • Create tests
  • Add docs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions