| 73 | #define FMT_RETRY(result, expression) FMT_RETRY_VAL(result, expression, -1) |
| 74 | |
| 75 | FMT_BEGIN_NAMESPACE |
| 76 | |
| 77 | /** |
| 78 | \rst |
| 79 | A reference to a null-terminated string. It can be constructed from a C |
| 80 | string or ``std::string``. |
| 81 | |
| 82 | You can use one of the following type aliases for common character types: |
| 83 | |
| 84 | +---------------+-----------------------------+ |
| 85 | | Type | Definition | |
| 86 | +===============+=============================+ |
| 87 | | cstring_view | basic_cstring_view<char> | |
| 88 | +---------------+-----------------------------+ |
| 89 | | wcstring_view | basic_cstring_view<wchar_t> | |
| 90 | +---------------+-----------------------------+ |
| 91 | |
| 92 | This class is most useful as a parameter type to allow passing |
| 93 | different types of strings to a function, for example:: |
| 94 | |
| 95 | template <typename... Args> |
| 96 | std::string format(cstring_view format_str, const Args & ... args); |
| 97 | |
| 98 | format("{}", 42); |
| 99 | format(std::string("{}"), 42); |
| 100 | \endrst |
| 101 | */ |
| 102 | template <typename Char> class basic_cstring_view { |
| 103 | private: |
| 104 | const Char* data_; |
| 105 | |
| 106 | public: |
| 107 | /** Constructs a string reference object from a C string. */ |
| 108 | basic_cstring_view(const Char* s) : data_(s) {} |
| 109 | |
| 110 | /** |
| 111 | \rst |
| 112 | Constructs a string reference from an ``std::string`` object. |
| 113 | \endrst |
| 114 | */ |
| 115 | basic_cstring_view(const std::basic_string<Char>& s) : data_(s.c_str()) {} |
| 116 | |
| 117 | /** Returns the pointer to a C string. */ |
| 118 | const Char* c_str() const { return data_; } |
| 119 | }; |
| 120 | |
| 121 | using cstring_view = basic_cstring_view<char>; |
nothing calls this directly
no outgoing calls
no test coverage detected