2
0

byte_container_with_subtype__clear_subtype.cpp 576 B

123456789101112131415161718192021
  1. #include <iostream>
  2. #include <nlohmann/json.hpp>
  3. // define a byte container based on std::vector
  4. using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
  5. using json = nlohmann::json;
  6. int main()
  7. {
  8. std::vector<std::uint8_t> bytes = {{0xca, 0xfe, 0xba, 0xbe}};
  9. // create container with subtype
  10. auto c1 = byte_container_with_subtype(bytes, 42);
  11. std::cout << "before calling clear_subtype(): " << json(c1) << '\n';
  12. c1.clear_subtype();
  13. std::cout << "after calling clear_subtype(): " << json(c1) << '\n';
  14. }