Advertisement
Guest User

Untitled

a guest
Jul 28th, 2013
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1.  
  2. #include <yas/binary_iarchive.hpp>
  3. #include <yas/binary_oarchive.hpp>
  4. #include <yas/serializers/binary/std/std_unordered_map_serializers.hpp>
  5.  
  6. #include <cassert>
  7. #include <iostream>
  8.  
  9. /***************************************************************************/
  10.  
  11. int main() {
  12.     using map_type = std::unordered_map<int, int>;
  13.  
  14.     enum {
  15.          k1 = 1
  16.         ,v1 = 2
  17.         ,k2 = 3
  18.         ,v2 = 4
  19.         ,size = 2
  20.     };
  21.     map_type omap = {
  22.          {k1, v1}
  23.         ,{k2, v2}
  24.     };
  25.  
  26.     yas::binary_mem_oarchive oa;
  27.     oa & omap;
  28.  
  29.     map_type imap;
  30.     yas::binary_mem_iarchive ia(oa.get_intrusive_buffer());
  31.     ia & imap;
  32.  
  33.     assert(imap.size() == size);
  34.     assert(imap.find(k1) != imap.end() && imap.at(k1) == v1);
  35.     assert(imap.find(k2) != imap.end() && imap.at(k2) == v2);
  36.  
  37.     return 0;
  38. }
  39.  
  40. /***************************************************************************/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement