Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-937

How to stream a std::size_t variable into bsoncxx::builder::stream::document

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • None
    • Affects Version/s: 3.0.1
    • Component/s: Implementation
    • Labels:
      None
    • Environment:
      Windows 10
      MS VS 2015
      MongoDB 3.3.5
      MongoDB C++11 Driver 3.0.1

      Class variable:

      std::size_t key_;

      Note: My class design is designed to be able to operate with any DB, not just MongoDB.

      Code:

      bsoncxx::builder::stream::document bsb_field_design;
      bsb_field_design << "t4id"   << field_design.id_
                       << "t4name" << field_design.name_
                       << "t4type" << field_design.type_
                       << "t4key"  << field_design.key_
      ...
      

      Gives a lengthy error (appended below) that (I believe) is saying it can't figure out how to handle size_t from the last line of the code.

      My (unsatisfying) solution:

             << "t4key" << static_cast<int>(field_design.key_)
      

      Is that my only solution?

      Error message:

      1>C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/stream/value_context.hpp(70): error C2668: 'bsoncxx::v_noabi::builder::core::append': ambiguous call to overloaded function
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(263): note: could be 'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::oid &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(258): note: or       'void bsoncxx::v_noabi::builder::core::append(int64_t)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(253): note: or       'void bsoncxx::v_noabi::builder::core::append(int32_t)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(248): note: or       'void bsoncxx::v_noabi::builder::core::append(double)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(243): note: or       'void bsoncxx::v_noabi::builder::core::append(bool)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(225): note: or       'void bsoncxx::v_noabi::builder::core::append(bsoncxx::stdx::string_view)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(220): note: or       'void bsoncxx::v_noabi::builder::core::append(std::string)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(215): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::value &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(210): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_maxkey &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(205): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_minkey &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(200): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_int64 &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(195): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_timestamp &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(190): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_int32 &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(185): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_codewscope &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(180): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_symbol &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(175): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_code &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(170): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_dbpointer &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(165): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_regex &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(160): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_null &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(155): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_date &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(150): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_bool &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(145): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_oid &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(140): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_undefined &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(135): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_binary &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(130): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_array &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(125): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_document &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(120): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_utf8 &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/core.hpp(115): note: or       'void bsoncxx::v_noabi::builder::core::append(const bsoncxx::v_noabi::types::b_double &)'
      1>  C:\build\install\include\bsoncxx\v_noabi\bsoncxx/builder/stream/value_context.hpp(70): note: while trying to match the argument list '(size_t)'
      1>  ..\..\..\..\..\..\..\T4 2.0\src\mongoDB\src\T4DBFileBlueprintFunctions.cpp(245): note: see reference to function template instantiation 'bsoncxx::v_noabi::builder::stream::key_context<bsoncxx::v_noabi::builder::stream::closed_context> bsoncxx::v_noabi::builder::stream::value_context<bsoncxx::v_noabi::builder::stream::key_context<bsoncxx::v_noabi::builder::stream::closed_context>>::operator <<<size_t&>(T)' being compiled
      1>          with
      1>          [
      1>              T=size_t &
      1>          ]
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            therefore George Thompson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: