Add encoder hook for std::tuple
This commit is contained in:
parent
2e9b507837
commit
4766b7940d
1 changed files with 20 additions and 0 deletions
20
LibCBOR/Include/CBOR/EncoderHooks.hpp
Normal file
20
LibCBOR/Include/CBOR/EncoderHooks.hpp
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef LIBCBOR_ENCODERHOOKS_HPP
|
||||||
|
#define LIBCBOR_ENCODERHOOKS_HPP
|
||||||
|
|
||||||
|
#include "Encoder.hpp"
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
namespace CBOR
|
||||||
|
{
|
||||||
|
template <typename... Args>
|
||||||
|
constexpr
|
||||||
|
void EncodeHook(CBOR::Encoder &encoder, const std::tuple<Args...> &tuple)
|
||||||
|
{
|
||||||
|
std::apply([&encoder] (const auto &...args) {
|
||||||
|
encoder.EncodeArray(args...);
|
||||||
|
}, tuple);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // LIBCBOR_ENCODERHOOKS_HPP
|
Loading…
Add table
Add a link
Reference in a new issue