Compare commits

...

20 Commits

Author SHA1 Message Date
Takatoshi Kondo
c00584281f Merge pull request #609 from redboltz/updated_to_2.1.3
Updated to version 2.1.3.
2017-06-15 23:58:21 +09:00
Takatoshi Kondo
45a0124ede Updated to version 2.1.3. 2017-06-15 22:37:33 +09:00
Takatoshi Kondo
ceb27348bd Merge pull request #608 from redboltz/add_cpp17_files
Added C++17 files to build setting.
2017-06-15 20:42:40 +09:00
Takatoshi Kondo
1ad737ee08 Added C++17 files to build setting. 2017-06-15 20:41:52 +09:00
Takatoshi Kondo
7024a1ec2c Merge pull request #607 from redboltz/fix_597
Solved #597.
2017-06-15 20:38:22 +09:00
Takatoshi Kondo
ca4a425a52 Merge pull request #602 from redboltz/fix_600
Fixed #600.
2017-06-15 16:08:24 +09:00
Takatoshi Kondo
a502097fd0 Solved #597.
Added `std::optional` and `std::string_view` adaptors.
2017-06-13 18:22:48 +09:00
Takatoshi Kondo
6b99a0c8b7 Merge branch 'jasperla-openbsd' 2017-06-13 12:51:27 +09:00
Takatoshi Kondo
1a3fcc3a22 Prevent iovec redefinition on C++. 2017-06-13 12:50:53 +09:00
Takatoshi Kondo
111739f8ce Merge branch 'openbsd' of https://github.com/jasperla/msgpack-c into jasperla-openbsd 2017-06-13 12:27:49 +09:00
Takatoshi Kondo
f638e2186b Merge pull request #605 from redboltz/fix_nonnull_warning
Fixed nonnull warnings on gcc 7.1.
2017-06-12 23:38:34 +09:00
Takatoshi Kondo
002376c678 Merge pull request #604 from redboltz/fix_gcc71_warning
Suppressed gcc 7.1 `maybe-uninitialized` warning.
2017-06-12 23:38:21 +09:00
Takatoshi Kondo
09a2f81b5f Merge pull request #603 from redboltz/add_missing_cmake_on_dist
Added a missing cmake file to makedist.sh.
2017-06-12 23:38:06 +09:00
Takatoshi Kondo
ffcaaeb482 Fixed #600.
Added `maybe-uninitialized` warning suppression code.
2017-06-12 15:33:05 +09:00
Takatoshi Kondo
bd511a4bd1 Fixed nonnull warnings on gcc 7.1. 2017-06-12 15:14:37 +09:00
Takatoshi Kondo
684c5e0bb0 Suppressed gcc 7.1 maybe-uninitialized warning.
When I execute cmake `-DMSGPACK_CXX11=OFF`, gcc 7.1 reports the warning.
I've already added the warning suppression pragma, but it doesn't work
in this case. So I added explicit initializing code even if it is redundant.
2017-06-12 14:11:21 +09:00
Takatoshi Kondo
8e74449181 Added a missing cmake file to makedist.sh. 2017-06-12 14:10:08 +09:00
Jasper Lievisse Adriaanse
f2b788e51f Sprinkle __OpenBSD__: include missing headers and prevent iovec redefinition 2017-06-11 18:13:10 +02:00
Takatoshi Kondo
7214b4c73f Merge pull request #599 from redboltz/fix_598
Fixed #598.
2017-06-08 20:44:21 +09:00
Takatoshi Kondo
a7a78bde9b Fixed #598. 2017-06-08 09:26:05 +00:00
22 changed files with 479 additions and 13 deletions

View File

@@ -1,3 +1,9 @@
# 2017-06-15 version 2.1.3
* Improve build system (#603)
* Add C++17 adaptors `std::optional` and `std::string_view`. (#607, #608)
* Improve cross platform configuration (#601)
* Remove some warnings (#599, #602, #605)
# 2017-06-07 version 2.1.2
* Improve documents (#565)

View File

@@ -50,7 +50,15 @@ IF (MSGPACK_USE_X3_PARSE)
ENDIF ()
ENDIF ()
ELSE ()
IF (MSGPACK_CXX11)
IF (MSGPACK_CXX17)
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET (CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}")
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET (CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}")
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
MESSAGE ( FATAL_ERROR "MSVC doesn't support C++17.")
ENDIF ()
ELSEIF (MSGPACK_CXX11)
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")

View File

@@ -180,6 +180,8 @@ IF (MSGPACK_ENABLE_CXX)
include/msgpack/adaptor/cpp11/unique_ptr.hpp
include/msgpack/adaptor/cpp11/unordered_map.hpp
include/msgpack/adaptor/cpp11/unordered_set.hpp
include/msgpack/adaptor/cpp17/optional.hpp
include/msgpack/adaptor/cpp17/string_view.hpp
include/msgpack/adaptor/define.hpp
include/msgpack/adaptor/define_decl.hpp
include/msgpack/adaptor/deque.hpp
@@ -528,6 +530,8 @@ IF (MSGPACK_ENABLE_CXX)
include/msgpack/v1/adaptor/cpp11/unique_ptr.hpp
include/msgpack/v1/adaptor/cpp11/unordered_map.hpp
include/msgpack/v1/adaptor/cpp11/unordered_set.hpp
include/msgpack/v1/adaptor/cpp17/optional.hpp
include/msgpack/v1/adaptor/cpp17/string_view.hpp
include/msgpack/v1/adaptor/define.hpp
include/msgpack/v1/adaptor/define_decl.hpp
include/msgpack/v1/adaptor/deque.hpp

View File

@@ -1,7 +1,7 @@
`msgpack` for C/C++
===================
Version 2.1.2 [![Build Status](https://travis-ci.org/msgpack/msgpack-c.svg?branch=master)](https://travis-ci.org/msgpack/msgpack-c) [![Build status](https://ci.appveyor.com/api/projects/status/8kstcgt79qj123mw/branch/master?svg=true)](https://ci.appveyor.com/project/redboltz/msgpack-c/branch/master)
Version 2.1.3 [![Build Status](https://travis-ci.org/msgpack/msgpack-c.svg?branch=master)](https://travis-ci.org/msgpack/msgpack-c) [![Build status](https://ci.appveyor.com/api/projects/status/8kstcgt79qj123mw/branch/master?svg=true)](https://ci.appveyor.com/project/redboltz/msgpack-c/branch/master)
It's like JSON but small and fast.

View File

@@ -1,4 +1,4 @@
version: 2.1.2.{build}
version: 2.1.3.{build}
image:
- Visual Studio 2015

View File

@@ -0,0 +1,16 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2017 KONDO Takatoshi
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef MSGPACK_TYPE_CPP17_OPTIONAL_HPP
#define MSGPACK_TYPE_CPP17_OPTIONAL_HPP
#include "msgpack/v1/adaptor/cpp17/optional.hpp"
#endif // MSGPACK_TYPE_CPP17_OPTIONAL_HPP

View File

@@ -0,0 +1,16 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2017 KONDO Takatoshi
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef MSGPACK_TYPE_CPP17_STRING_VIEW_HPP
#define MSGPACK_TYPE_CPP17_STRING_VIEW_HPP
#include "msgpack/v1/adaptor/cpp17/string_view.hpp"
#endif // MSGPACK_TYPE_CPP17_STRING_VIEW_HPP

View File

@@ -77,7 +77,7 @@
# endif
# endif
#elif defined(unix) || defined(__unix) || defined(__APPLE__)
#elif defined(unix) || defined(__unix) || defined(__APPLE__) || defined(__OpenBSD__)
#include <arpa/inet.h> /* __BYTE_ORDER */
# if defined(linux)
@@ -88,7 +88,7 @@
#if MSGPACK_ENDIAN_LITTLE_BYTE
# if defined(unix) || defined(__unix) || defined(__APPLE__)
# if defined(unix) || defined(__unix) || defined(__APPLE__) || defined(__OpenBSD__)
# define _msgpack_be16(x) ntohs(x)
# else
# if defined(ntohs)
@@ -102,7 +102,7 @@
# endif
# endif
# if defined(unix) || defined(__unix) || defined(__APPLE__)
# if defined(unix) || defined(__unix) || defined(__APPLE__) || defined(__OpenBSD__)
# define _msgpack_be32(x) ntohl(x)
# else
# if defined(ntohl)

View File

@@ -42,6 +42,13 @@
#include "adaptor/cpp11/unordered_map.hpp"
#include "adaptor/cpp11/unordered_set.hpp"
#if __cplusplus >= 201703
#include "adaptor/cpp17/optional.hpp"
#include "adaptor/cpp17/string_view.hpp"
#endif // __cplusplus >= 201703
#endif // defined(MSGPACK_USE_CPP03)
#if defined(MSGPACK_USE_BOOST)

View File

@@ -45,6 +45,13 @@ struct convert<std::array<char, N>> {
}
};
template <>
struct convert<std::array<char, 0>> {
msgpack::object const& operator()(msgpack::object const& o, std::array<char, 0>&) const {
return o;
}
};
template <std::size_t N>
struct pack<std::array<char, N>> {
template <typename Stream>

View File

@@ -45,6 +45,13 @@ struct convert<std::array<unsigned char, N>> {
}
};
template <>
struct convert<std::array<unsigned char, 0>> {
msgpack::object const& operator()(msgpack::object const& o, std::array<unsigned char, 0>&) const {
return o;
}
};
template <std::size_t N>
struct pack<std::array<unsigned char, N>> {
template <typename Stream>

View File

@@ -0,0 +1,90 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2017 KONDO Takatoshi
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef MSGPACK_V1_TYPE_OPTIONAL_HPP
#define MSGPACK_V1_TYPE_OPTIONAL_HPP
#if __cplusplus >= 201703
#include "msgpack/versioning.hpp"
#include "msgpack/adaptor/adaptor_base.hpp"
#include "msgpack/adaptor/check_container_size.hpp"
#include <optional>
namespace msgpack {
/// @cond
MSGPACK_API_VERSION_NAMESPACE(v1) {
/// @endcond
namespace adaptor {
#if !defined (MSGPACK_USE_CPP03)
template <typename T>
struct as<std::optional<T>, typename std::enable_if<msgpack::has_as<T>::value>::type> {
std::optional<T> operator()(msgpack::object const& o) const {
if(o.is_nil()) return std::nullopt;
return o.as<T>();
}
};
#endif // !defined (MSGPACK_USE_CPP03)
template <typename T>
struct convert<std::optional<T> > {
msgpack::object const& operator()(msgpack::object const& o, std::optional<T>& v) const {
if(o.is_nil()) v = std::nullopt;
else {
T t;
msgpack::adaptor::convert<T>()(o, t);
v = t;
}
return o;
}
};
template <typename T>
struct pack<std::optional<T> > {
template <typename Stream>
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::optional<T>& v) const {
if (v) o.pack(*v);
else o.pack_nil();
return o;
}
};
template <typename T>
struct object<std::optional<T> > {
void operator()(msgpack::object& o, const std::optional<T>& v) const {
if (v) msgpack::adaptor::object<T>()(o, *v);
else o.type = msgpack::type::NIL;
}
};
template <typename T>
struct object_with_zone<std::optional<T> > {
void operator()(msgpack::object::with_zone& o, const std::optional<T>& v) const {
if (v) msgpack::adaptor::object_with_zone<T>()(o, *v);
else o.type = msgpack::type::NIL;
}
};
} // namespace adaptor
/// @cond
} // MSGPACK_API_VERSION_NAMESPACE(v1)
/// @endcond
} // namespace msgpack
#endif // __cplusplus >= 201703
#endif // MSGPACK_V1_TYPE_OPTIONAL_HPP

View File

@@ -0,0 +1,86 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2017 KONDO Takatoshi
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef MSGPACK_V1_TYPE_STRING_VIEW_HPP
#define MSGPACK_V1_TYPE_STRING_VIEW_HPP
#if __cplusplus >= 201703
#include "msgpack/versioning.hpp"
#include "msgpack/adaptor/adaptor_base.hpp"
#include "msgpack/adaptor/check_container_size.hpp"
#include <string_view>
namespace msgpack {
/// @cond
MSGPACK_API_VERSION_NAMESPACE(v1) {
/// @endcond
namespace adaptor {
template <>
struct convert<std::string_view> {
msgpack::object const& operator()(msgpack::object const& o, std::string_view& v) const {
switch (o.type) {
case msgpack::type::BIN:
v = std::string_view(o.via.bin.ptr, o.via.bin.size);
break;
case msgpack::type::STR:
v = std::string_view(o.via.str.ptr, o.via.str.size);
break;
default:
throw msgpack::type_error();
break;
}
return o;
}
};
template <>
struct pack<std::string_view> {
template <typename Stream>
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::string_view& v) const {
uint32_t size = checked_get_container_size(v.size());
o.pack_str(size);
o.pack_str_body(v.data(), size);
return o;
}
};
template <>
struct object<std::string_view> {
void operator()(msgpack::object& o, const std::string_view& v) const {
uint32_t size = checked_get_container_size(v.size());
o.type = msgpack::type::STR;
o.via.str.ptr = v.data();
o.via.str.size = size;
}
};
template <>
struct object_with_zone<std::string_view> {
void operator()(msgpack::object::with_zone& o, const std::string_view& v) const {
static_cast<msgpack::object&>(o) << v;
}
};
} // namespace adaptor
/// @cond
} // MSGPACK_API_VERSION_NAMESPACE(v1)
/// @endcond
} // namespace msgpack
#endif // __cplusplus >= 201703
#endif // MSGPACK_V1_TYPE_STRING_VIEW_HPP

View File

@@ -1,7 +1,7 @@
//
// MessagePack for C++ zero-copy buffer implementation
//
// Copyright (C) 2008-2013 FURUHASHI Sadayuki and KONDO Takatoshi
// Copyright (C) 2008-2017 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -22,7 +22,7 @@
#endif
#endif // defined(_MSC_VER)
#ifndef _WIN32
#if defined(unix) || defined(__unix) || defined(__APPLE__) || defined(__OpenBSD__)
#include <sys/uio.h>
#else
struct iovec {

View File

@@ -1,3 +1,3 @@
#define MSGPACK_VERSION_MAJOR 2
#define MSGPACK_VERSION_MINOR 1
#define MSGPACK_VERSION_REVISION 2
#define MSGPACK_VERSION_REVISION 3

View File

@@ -13,7 +13,7 @@
#include "zone.h"
#include <stdlib.h>
#if defined(unix) || defined(__unix) || defined(__APPLE__)
#if defined(unix) || defined(__unix) || defined(__APPLE__) || defined(__OpenBSD__)
#include <sys/uio.h>
#else
struct iovec {

View File

@@ -34,6 +34,7 @@ tar --append --file=$filename $prefix/COPYING
tar --append --file=$filename $prefix/README
tar --append --file=$filename $prefix/msgpack_vc8.sln
tar --append --file=$filename $prefix/msgpack_vc8.vcproj
tar --append --file=$filename $prefix/msgpack-config.cmake.in
rm -f $prefix

View File

@@ -66,6 +66,12 @@ IF (MSGPACK_CXX11)
)
ENDIF ()
IF (MSGPACK_CXX17)
LIST (APPEND check_PROGRAMS
msgpack_cpp17.cpp
)
ENDIF ()
FOREACH (source_file ${check_PROGRAMS})
GET_FILENAME_COMPONENT (source_file_we ${source_file} NAME_WE)
ADD_EXECUTABLE (

View File

@@ -20,6 +20,10 @@ static void feed_file(msgpack::unpacker& pac, const char* path)
TEST(cases, format)
{
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
msgpack::unpacker pac;
msgpack::unpacker pac_compact;
@@ -34,4 +38,7 @@ TEST(cases, format)
}
EXPECT_FALSE( pac_compact.next(oh) );
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
}

View File

@@ -776,7 +776,6 @@ TEST(MSGPACKC, simple_buffer_str_fix_l)
EXPECT_EQ(MSGPACK_UNPACK_SUCCESS, ret);
EXPECT_EQ(MSGPACK_OBJECT_STR, obj.type);
EXPECT_EQ(str_size, obj.via.str.size);
EXPECT_EQ(0, memcmp(str, obj.via.str.ptr, str_size));
msgpack_zone_destroy(&z);
msgpack_sbuffer_destroy(&sbuf);
@@ -975,7 +974,6 @@ TEST(MSGPACKC, simple_buffer_v4raw_fix_l)
EXPECT_EQ(MSGPACK_UNPACK_SUCCESS, ret);
EXPECT_EQ(MSGPACK_OBJECT_STR, obj.type);
EXPECT_EQ(str_size, obj.via.str.size);
EXPECT_EQ(0, memcmp(str, obj.via.str.ptr, str_size));
msgpack_zone_destroy(&z);
msgpack_sbuffer_destroy(&sbuf);

207
test/msgpack_cpp17.cpp Normal file
View File

@@ -0,0 +1,207 @@
#include <msgpack.hpp>
#include <gtest/gtest.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#if !defined(MSGPACK_USE_CPP03) && __cplusplus >= 201703
// C++17
TEST(MSGPACK_CPP17, optional_pack_convert_nil)
{
std::stringstream ss;
std::optional<int> val1;
msgpack::pack(ss, val1);
msgpack::object_handle oh =
msgpack::unpack(ss.str().data(), ss.str().size());
std::optional<int> val2 = oh.get().as<std::optional<int> >();
EXPECT_TRUE(val1 == val2);
}
TEST(MSGPACK_CPP17, optional_pack_convert_int)
{
std::stringstream ss;
std::optional<int> val1 = 1;
msgpack::pack(ss, val1);
msgpack::object_handle oh =
msgpack::unpack(ss.str().data(), ss.str().size());
std::optional<int> val2 = oh.get().as<std::optional<int> >();
EXPECT_TRUE(val1 == val2);
}
TEST(MSGPACK_CPP17, optional_pack_convert_vector)
{
typedef std::optional<std::vector<int> > ovi_t;
std::stringstream ss;
ovi_t val1;
std::vector<int> v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
val1 = v;
msgpack::pack(ss, val1);
msgpack::object_handle oh =
msgpack::unpack(ss.str().data(), ss.str().size());
ovi_t val2 = oh.get().as<ovi_t>();
EXPECT_TRUE(val1 == val2);
}
TEST(MSGPACK_CPP17, optional_pack_convert_vector_optional)
{
typedef std::vector<std::optional<int> > voi_t;
std::stringstream ss;
voi_t val1;
val1.resize(3);
val1[0] = 1;
val1[2] = 3;
msgpack::pack(ss, val1);
msgpack::object_handle oh =
msgpack::unpack(ss.str().data(), ss.str().size());
voi_t val2 = oh.get().as<voi_t>();
EXPECT_TRUE(val1 == val2);
}
TEST(MSGPACK_CPP17, optional_object_nil)
{
std::optional<int> val1;
msgpack::object obj(val1);
std::optional<int> val2 = obj.as<std::optional<int> >();
EXPECT_TRUE(val1 == val2);
}
TEST(MSGPACK_CPP17, optional_object_int)
{
std::optional<int> val1 = 1;
msgpack::object obj(val1);
std::optional<int> val2 = obj.as<std::optional<int> >();
EXPECT_TRUE(val1 == val2);
}
// Compile error as expected
/*
TEST(MSGPACK_CPP17, optional_object_vector)
{
typedef std::optional<std::vector<int> > ovi_t;
ovi_t val1;
std::vector<int> v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
val1 = v;
msgpack::object obj(val1);
ovi_t val2 = obj.as<ovi_t>();
EXPECT_TRUE(val1 == val2);
}
*/
TEST(MSGPACK_CPP17, optional_object_with_zone_nil)
{
msgpack::zone z;
std::optional<int> val1;
msgpack::object obj(val1, z);
std::optional<int> val2 = obj.as<std::optional<int> >();
EXPECT_TRUE(val1 == val2);
}
TEST(MSGPACK_CPP17, optional_object_with_zone_int)
{
msgpack::zone z;
std::optional<int> val1 = 1;
msgpack::object obj(val1, z);
std::optional<int> val2 = obj.as<std::optional<int> >();
EXPECT_TRUE(val1 == val2);
}
TEST(MSGPACK_CPP17, optional_object_with_zone_vector_optional)
{
typedef std::vector<std::optional<int> > voi_t;
msgpack::zone z;
voi_t val1;
val1.resize(3);
val1[0] = 1;
val1[2] = 3;
msgpack::object obj(val1, z);
voi_t val2 = obj.as<voi_t>();
EXPECT_TRUE(val1 == val2);
}
struct no_def_con {
no_def_con() = delete;
no_def_con(int i):i(i) {}
int i;
MSGPACK_DEFINE(i);
};
inline bool operator==(no_def_con const& lhs, no_def_con const& rhs) {
return lhs.i == rhs.i;
}
inline bool operator!=(no_def_con const& lhs, no_def_con const& rhs) {
return !(lhs == rhs);
}
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
namespace adaptor {
template <>
struct as<no_def_con> {
no_def_con operator()(msgpack::object const& o) const {
if (o.type != msgpack::type::ARRAY) throw msgpack::type_error();
if (o.via.array.size != 1) throw msgpack::type_error();
return no_def_con(o.via.array.ptr[0].as<int>());
}
};
} // adaptor
} // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
} // msgpack
TEST(MSGPACK_CPP17, optional_pack_convert_no_def_con)
{
std::stringstream ss;
std::optional<no_def_con> val1 = no_def_con(1);
msgpack::pack(ss, val1);
msgpack::object_handle oh =
msgpack::unpack(ss.str().data(), ss.str().size());
std::optional<no_def_con> val2 = oh.get().as<std::optional<no_def_con>>();
EXPECT_TRUE(val1 == val2);
}
TEST(MSGPACK_CPP17, string_view_pack_convert_string_view)
{
std::stringstream ss;
std::string s = "ABC";
std::string_view val1(s);
msgpack::pack(ss, val1);
msgpack::object_handle oh;
msgpack::unpack(oh, ss.str().data(), ss.str().size());
std::string_view val2 = oh.get().as<std::string_view>();
EXPECT_TRUE(val1 == val2);
}
TEST(MSGPACK_CPP17, string_view_object_strinf_view)
{
std::string s = "ABC";
std::string_view val1(s);
msgpack::object obj(val1);
std::string_view val2 = obj.as<std::string_view>();
EXPECT_TRUE(val1 == val2);
}
TEST(MSGPACK_CPP17, string_view_object_with_zone_string_view)
{
msgpack::zone z;
std::string s = "ABC";
std::string_view val1(s);
msgpack::object obj(val1, z);
std::string_view val2 = obj.as<std::string_view>();
EXPECT_TRUE(val1 == val2);
}
#endif // !defined(MSGPACK_USE_CPP03) && __cplusplus >= 201703

View File

@@ -152,7 +152,7 @@ public:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
msgpack::type::tuple<bool, msgpack::object> tuple;
msgpack::type::tuple<bool, msgpack::object> tuple(false, msgpack::object());
o.convert(tuple);
is_double = tuple.get<0>();