mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-08 12:21:17 +00:00
emitter: Support std::string_view
Accept Emitter::operator<<(std::string_view). ABI remains C++11 compatible by exposing new method Emitter::Write(const char*, size_t). All affected calls optimized to pass std::string values as pointer + size tuple into appropriate routines.
This commit is contained in:

committed by
Jesse Beder

parent
8a9a7b74ef
commit
7470c2d871
@@ -46,6 +46,26 @@ TEST_F(EmitterTest, SimpleScalar) {
|
||||
ExpectEmit("Hello, World!");
|
||||
}
|
||||
|
||||
TEST_F(EmitterTest, SimpleStdStringScalar) {
|
||||
out << std::string("Hello, std string");
|
||||
|
||||
ExpectEmit("Hello, std string");
|
||||
}
|
||||
|
||||
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
|
||||
TEST_F(EmitterTest, SimpleStdStringViewScalar) {
|
||||
out << std::string_view("Hello, std string view");
|
||||
|
||||
ExpectEmit("Hello, std string view");
|
||||
}
|
||||
|
||||
TEST_F(EmitterTest, UnterminatedStdStringViewScalar) {
|
||||
out << std::string_view("HelloUnterminated", 5);
|
||||
|
||||
ExpectEmit("Hello");
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_F(EmitterTest, SimpleQuotedScalar) {
|
||||
Node n(Load("\"test\""));
|
||||
out << n;
|
||||
|
Reference in New Issue
Block a user