Skip to content

Commit d01156c

Browse files
author
me
committed
updated readme
1 parent 039347f commit d01156c

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
![Windows](https://github.com/pfeatherstone/msgpack_cpp/actions/workflows/windows.yml/badge.svg)
44

55
# msgpack_cpp
6-
C++ header-only msgpack library using kiss principle
6+
C++ header-only msgpack library
77

88
## Example
99

@@ -21,13 +21,13 @@ std::vector<char> buf;
2121
// Creates a lambda which captures `buf` by reference and appends data to it when invoked
2222
auto out = sink(buf);
2323
24-
// The first argument can be any function object with signature void(const char* data, size_t len)
24+
// The first argument can be any function object with signature void(const char* data, size_t len) (when C++20 is used, it satisfies the sink_type concept)
2525
serialize(out, a);
2626
2727
// Creates a mutable lambda which captures `buf` by reference and reads data from it when invoked
2828
auto in = source(buf);
2929
30-
// The first argument can be any function object with signature void(char* data, size_t len)
30+
// The first argument can be any function object with signature void(char* data, size_t len) (when C++20 is used, it satisfies the source_type concept)
3131
deserialize(in, a);
3232
```
3333

@@ -82,14 +82,14 @@ namespace mynamespace
8282
std::vector<short> my_audio;
8383
};
8484
85-
template<class Stream>
86-
void serialize(Stream& out, const my_struct1& obj)
85+
template<SINK_TYPE Sink>
86+
void serialize(Sink& out, const my_struct1& obj)
8787
{
8888
using msgpackcpp::serialize;
8989
serialize(out, std::tie(obj.my_int, obj.my_float, obj.my_string, obj.my_audio));
9090
}
9191
92-
template<class Source>
92+
template<SOURCE_TYPE Source>
9393
void deserialize(Source& in, my_struct1& obj)
9494
{
9595
using msgpackcpp::deserialize;

include/msgpack.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,16 @@
2828

2929
namespace msgpackcpp
3030
{
31-
template<class F>
32-
concept sink_type = std::invocable<F, const char*, std::size_t>;
33-
34-
template<class F>
35-
concept source_type = std::invocable<F, char*, std::size_t>;
31+
template<class F> concept sink_type = std::invocable<F, const char*, std::size_t>;
32+
template<class F> concept source_type = std::invocable<F, char*, std::size_t>;
3633
}
3734

38-
#define SINK_TYPE msgpackcpp::sink_type
35+
#define SINK_TYPE msgpackcpp::sink_type
3936
#define SOURCE_TYPE msgpackcpp::source_type
4037

4138
#else
42-
4339
#define SINK_TYPE class
4440
#define SOURCE_TYPE class
45-
4641
#endif
4742

4843
namespace msgpackcpp

0 commit comments

Comments
 (0)