Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msgpack.hpp 不支持char[] #39

Open
asing325 opened this issue Oct 12, 2018 · 2 comments
Open

msgpack.hpp 不支持char[] #39

asing325 opened this issue Oct 12, 2018 · 2 comments

Comments

@asing325
Copy link
Contributor

asing325 commented Oct 12, 2018

json.hpp支持char[],但是换成msgpack就编译失败了,
请看看能不能支持一下啊,第三方接口里面有char[],没有办法回避~


#include <iguana/msgpack.hpp>

namespace client
{
struct game
{
char ip[32]; // add for test
std::string name;
double price;
};
REFLECTION(game,ip, name, price);
}


编译错误

1>------ 已启动生成: 项目: msgpack_example, 配置: Debug Win32 ------
1>msgpack_example.cpp
\iguana\iguana\reflection.hpp(388): error C2672: “std::make_tuple”: 未找到匹配的重载函数

@awaa
Copy link

awaa commented Jun 15, 2023

char[n] 这样的在很多sdk都是这么声明的。期待实现

@awaa
Copy link

awaa commented Jun 16, 2023

lazy

template <typename T>
concept char_array_t = std::is_same_v<typename std::remove_extent<T>::type, char>;

template <class T>
concept str_t =
    std::convertible_to<std::decay_t<T>, std::string_view> && !str_view_t<T>
    && !char_array_t<T>;

template <typename Type>
concept fixed_array = (c_array<Type> || array<Type>)
            && !char_array_t<Type>;

template<char_array_t U, class It, size_t n>
IGUANA_INLINE void parse_item(U(&charArray)[n], It&& it, It&& end) {
    std::string parsed_str;
    parse_item<std::string, It>(parsed_str, it, end);
    parsed_str.copy(charArray, n-1);
}

template <typename Stream, char_array_t T, size_t n>
IGUANA_INLINE void render_json_value(Stream& ss, T(&t)[n]) {
    ss.push_back('"');
    ss.append(t);
    ss.push_back('"');


@bbbgan bbbgan pinned this issue Jun 28, 2023
@bbbgan bbbgan unpinned this issue Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants