Casey Carter 96f1cd2427 [libc++][test] Silence MSVC warning
Our static analyzer likes to warn when loop bodies are never executed, which is true for `make_string<T>("")`. Build the result with `basic_string`'s iterator-pair constructor instead, which is simpler (one liner), faster (single pass), and doesn't trigger the warning.

Differential Revision: https://reviews.llvm.org/D141263
2023-01-09 15:05:31 -08:00

18 lines
518 B
C++

#ifndef TEST_STD_RANGES_RANGE_FACTORIES_RANGE_ISTREAM_UTILS_H
#define TEST_STD_RANGES_RANGE_FACTORIES_RANGE_ISTREAM_UTILS_H
#include <sstream>
#include <string>
template <class CharT, std::size_t N>
auto make_string(const char (&in)[N]) {
return std::basic_string<CharT>(in + 0, in + (N - 1));
}
template <class CharT, std::size_t N>
auto make_string_stream(const char (&in)[N]) {
return std::basic_istringstream<CharT>(make_string<CharT>(in));
}
#endif //TEST_STD_RANGES_RANGE_FACTORIES_RANGE_ISTREAM_UTILS_H