Use ssize if available

This commit is contained in:
Rob Loach 2026-05-02 19:31:36 -04:00
parent 525cb4cda7
commit fbde6e7792
No known key found for this signature in database
GPG Key ID: 627C60834A74A21A

View File

@ -2941,7 +2941,11 @@ namespace chaiscript {
/// Parses the given input string, tagging parsed ast_nodes with the given m_filename. /// Parses the given input string, tagging parsed ast_nodes with the given m_filename.
AST_NodePtr parse_internal(const std::string &t_input, std::string t_fname) { AST_NodePtr parse_internal(const std::string &t_input, std::string t_fname) {
const auto begin = t_input.empty() ? nullptr : &t_input.front(); const auto begin = t_input.empty() ? nullptr : &t_input.front();
const auto end = begin == nullptr ? nullptr : std::next(begin, (int)std::size(t_input)); // std::ssize() isn't available in C++17 #if __cplusplus >= 202002L
const auto end = begin == nullptr ? nullptr : std::next(begin, std::ssize(t_input));
#else
const auto end = begin == nullptr ? nullptr : std::next(begin, (int)std::size(t_input));
#endif
m_position = Position(begin, end); m_position = Position(begin, end);
m_filename = std::make_shared<std::string>(std::move(t_fname)); m_filename = std::make_shared<std::string>(std::move(t_fname));