Skip to content

Commit ea3a026

Browse files
committed
use feature-test macros [skip ci]
1 parent 98e8a6a commit ea3a026

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

simplecpp.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020
#include <string>
2121
#include <unordered_map>
2222
#include <vector>
23+
#if __cplusplus >= 202002L
24+
# include <version>
25+
#endif
2326

24-
#if (__cplusplus >= 201703L) && (__cplusplus < 202002L)
27+
#if defined(__cpp_lib_string_view) && !defined(__cpp_lib_span)
2528
#include <string_view>
2629
#endif
27-
#if __cplusplus >= 202002L
30+
#ifdef __cpp_lib_span
2831
#include <span>
2932
#endif
3033

@@ -56,8 +59,8 @@
5659
// provide unsafe (i.e. raw pointer) API for TokenList
5760
// note: std::istream has an overhead compared to raw pointers
5861
#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)
6164
# define SIMPLECPP_UNSAFE_API
6265
# endif
6366
#endif
@@ -243,13 +246,13 @@ namespace simplecpp {
243246
: TokenList(reinterpret_cast<const unsigned char*>(data), size, filenames, filename, outputList, 0)
244247
{}
245248
#endif
246-
#if (__cplusplus >= 201703L) && (__cplusplus < 202002L)
249+
#if defined(__cpp_lib_string_view) && !defined(__cpp_lib_span)
247250
/** generates a token list from the given buffer */
248251
TokenList(std::string_view data, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
249252
: TokenList(reinterpret_cast<const unsigned char*>(data.data()), data.size(), filenames, filename, outputList, 0)
250253
{}
251254
#endif
252-
#if __cplusplus >= 202002L
255+
#ifdef __cpp_lib_span
253256
/** generates a token list from the given buffer */
254257
TokenList(std::span<char> data, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
255258
: TokenList(data.data(), data.size(), filenames, filename, outputList, 0)

0 commit comments

Comments
 (0)