byte_container_with_subtype__has_subtype.cpp 602 B

12345678910111213141516171819
  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. int main()
  6. {
  7. std::vector<std::uint8_t> bytes = {{0xca, 0xfe, 0xba, 0xbe}};
  8. // create container
  9. auto c1 = byte_container_with_subtype(bytes);
  10. // create container with subtype
  11. auto c2 = byte_container_with_subtype(bytes, 42);
  12. std::cout << std::boolalpha << "c1.has_subtype() = " << c1.has_subtype()
  13. << "\nc2.has_subtype() = " << c2.has_subtype() << std::endl;
  14. }