|
20 | 20 | #include <string> |
21 | 21 | #include <unordered_map> |
22 | 22 | #include <vector> |
| 23 | +#if __cplusplus >= 202002L |
| 24 | +# include <version> |
| 25 | +#endif |
23 | 26 |
|
24 | | -#if (__cplusplus >= 201703L) && (__cplusplus < 202002L) |
| 27 | +#if defined(__cpp_lib_string_view) && !defined(__cpp_lib_span) |
25 | 28 | #include <string_view> |
26 | 29 | #endif |
27 | | -#if __cplusplus >= 202002L |
| 30 | +#ifdef __cpp_lib_span |
28 | 31 | #include <span> |
29 | 32 | #endif |
30 | 33 |
|
|
56 | 59 | // provide unsafe (i.e. raw pointer) API for TokenList |
57 | 60 | // note: std::istream has an overhead compared to raw pointers |
58 | 61 | #ifndef SIMPLECPP_UNSAFE_API |
59 | | -// still provide the unsafe API for standards which lack the performant wrappers |
60 | | -# if __cplusplus < 201703L |
| 62 | +// still provide the unsafe API in case we lack the performant wrappers |
| 63 | +# if !defined(__cpp_lib_string_view) && !defined(__cpp_lib_span) |
61 | 64 | # define SIMPLECPP_UNSAFE_API |
62 | 65 | # endif |
63 | 66 | #endif |
@@ -243,13 +246,13 @@ namespace simplecpp { |
243 | 246 | : TokenList(reinterpret_cast<const unsigned char*>(data), size, filenames, filename, outputList, 0) |
244 | 247 | {} |
245 | 248 | #endif |
246 | | -#if (__cplusplus >= 201703L) && (__cplusplus < 202002L) |
| 249 | +#if defined(__cpp_lib_string_view) && !defined(__cpp_lib_span) |
247 | 250 | /** generates a token list from the given buffer */ |
248 | 251 | TokenList(std::string_view data, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr) |
249 | 252 | : TokenList(reinterpret_cast<const unsigned char*>(data.data()), data.size(), filenames, filename, outputList, 0) |
250 | 253 | {} |
251 | 254 | #endif |
252 | | -#if __cplusplus >= 202002L |
| 255 | +#ifdef __cpp_lib_span |
253 | 256 | /** generates a token list from the given buffer */ |
254 | 257 | TokenList(std::span<char> data, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr) |
255 | 258 | : TokenList(data.data(), data.size(), filenames, filename, outputList, 0) |
|
0 commit comments