13
13
#include < variant>
14
14
#include < vector>
15
15
16
+ #include " ../Box.hpp"
16
17
#include " ../Ref.hpp"
17
18
#include " ../Result.hpp"
18
19
#include " ../always_false.hpp"
@@ -102,20 +103,20 @@ class Writer {
102
103
103
104
OutputObjectType add_object_to_array (
104
105
const size_t _size, OutputArrayType* _parent) const noexcept {
105
- subdocs_->push_back ( BSONType{} );
106
+ subdocs_->emplace_back (rfl::Box< BSONType>() );
106
107
bson_array_builder_append_document_begin (_parent->val_ ,
107
- &subdocs_->back (). val_ );
108
- return OutputObjectType (&subdocs_->back (). val_ , IsArray{_parent->val_ });
108
+ &( subdocs_->back ()-> val_ ) );
109
+ return OutputObjectType (&subdocs_->back ()-> val_ , IsArray{_parent->val_ });
109
110
}
110
111
111
112
OutputObjectType add_object_to_object (
112
113
const std::string& _name, const size_t _size,
113
114
OutputObjectType* _parent) const noexcept {
114
- subdocs_->push_back ( BSONType{} );
115
+ subdocs_->emplace_back (rfl::Box< BSONType>() );
115
116
bson_append_document_begin (_parent->val_ , _name.c_str (),
116
117
static_cast <int >(_name.size ()),
117
- &subdocs_->back (). val_ );
118
- return OutputObjectType (&subdocs_->back (). val_ , IsObject{_parent->val_ });
118
+ &( subdocs_->back ()-> val_ ) );
119
+ return OutputObjectType (&subdocs_->back ()-> val_ , IsObject{_parent->val_ });
119
120
}
120
121
121
122
template <class T >
@@ -131,7 +132,7 @@ class Writer {
131
132
static_cast <double >(_var));
132
133
} else if constexpr (std::is_integral<std::remove_cvref_t <T>>()) {
133
134
bson_array_builder_append_int64 (_parent->val_ ,
134
- static_cast <std::int32_t >(_var));
135
+ static_cast <std::int64_t >(_var));
135
136
} else {
136
137
static_assert (rfl::always_false_v<T>, " Unsupported type." );
137
138
}
@@ -155,7 +156,7 @@ class Writer {
155
156
} else if constexpr (std::is_integral<std::remove_cvref_t <T>>()) {
156
157
bson_append_int64 (_parent->val_ , _name.c_str (),
157
158
static_cast <int >(_name.size ()),
158
- static_cast <std::int32_t >(_var));
159
+ static_cast <std::int64_t >(_var));
159
160
} else {
160
161
static_assert (rfl::always_false_v<T>, " Unsupported type." );
161
162
}
@@ -211,7 +212,7 @@ class Writer {
211
212
bson_t * const doc_;
212
213
213
214
// / Contain all of the subdocuments.
214
- const rfl::Ref<std::vector<BSONType>> subdocs_;
215
+ const rfl::Ref<std::vector<rfl::Box< BSONType> >> subdocs_;
215
216
};
216
217
217
218
} // namespace bson
0 commit comments