Skip to content

Commit

Permalink
gcc8
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos committed Jul 2, 2024
1 parent f7bd683 commit d26edb9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion iguana/pb_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ IGUANA_INLINE void to_pb_impl(Type&& t, It&& it, uint32_t*& sz_ptr) {
}
}

#if defined(__clang__) || defined(_MSC_VER) || \
(defined(__GNUC__) && __GNUC__ > 8)
template <typename T>
IGUANA_INLINE constexpr std::string_view get_type_string() {
if constexpr (std::is_integral_v<T>) {
Expand Down Expand Up @@ -443,7 +445,7 @@ IGUANA_INLINE void build_sub_proto(Map& map, std::string_view str_type,
map.emplace(str_type, std::move(sub_str));
}
}

#endif
} // namespace detail

template <typename T, typename Stream>
Expand All @@ -455,6 +457,8 @@ IGUANA_INLINE void to_pb(T& t, Stream& out) {
detail::to_pb_impl<0>(t, &out[0], sz_ptr);
}

#if defined(__clang__) || defined(_MSC_VER) || \
(defined(__GNUC__) && __GNUC__ > 8)
template <typename T, bool gen_header = true, typename Stream>
IGUANA_INLINE void to_proto(Stream& out, std::string_view ns = "") {
if (gen_header) {
Expand Down Expand Up @@ -484,6 +488,7 @@ IGUANA_INLINE void to_proto_file(Stream& stream, std::string_view ns = "") {
to_proto<T, gen_header>(out, ns);
stream.write(out.data(), out.size());
}
#endif

template <typename T, typename Stream>
IGUANA_INLINE void to_pb_adl(iguana_adl_t* p, T& t, Stream& out) {
Expand Down
3 changes: 3 additions & 0 deletions test/test_pb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ struct vector_t {
};
REFLECTION(vector_t, id, color, variant, ids, pairs, strs, map, name, op_val);

#if defined(__clang__) || defined(_MSC_VER) || \
(defined(__GNUC__) && __GNUC__ > 8)
TEST_CASE("struct to proto") {
{
std::string str;
Expand Down Expand Up @@ -333,6 +335,7 @@ TEST_CASE("struct to proto") {
CHECK(str.find("int32 age = 3;") != std::string::npos);
}
}
#endif

TEST_CASE("test reflection") {
{
Expand Down
3 changes: 3 additions & 0 deletions test/test_proto3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ TEST_CASE("test RepeatIguanaTypeMsg") {
}

TEST_CASE("test NestedMsg") {
#if defined(__clang__) || defined(_MSC_VER) || \
(defined(__GNUC__) && __GNUC__ > 8)
{
std::string str;
iguana::to_proto<stpb::NestedMsg>(str, "test");
Expand All @@ -305,6 +307,7 @@ TEST_CASE("test NestedMsg") {
std::ofstream out("NestedMsg.proto", std::ios::binary);
iguana::to_proto_file<stpb::NestedMsg>(out, "test");
}
#endif
{
stpb::NestedMsg se_st{
/* base_msg */ stpb::BaseTypeMsg{100, 200, 300, 400, 31.4f, 62.8, false,
Expand Down

0 comments on commit d26edb9

Please sign in to comment.