MongoDB C++ Driver mongocxx-3.10.1
Loading...
Searching...
No Matches
impl.hpp
1// Copyright 2015 MongoDB Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <bsoncxx/builder/basic/sub_array.hpp>
18#include <bsoncxx/builder/basic/sub_document.hpp>
19#include <bsoncxx/stdx/type_traits.hpp>
20
21#include <bsoncxx/config/prelude.hpp>
22
23namespace bsoncxx {
24namespace v_noabi {
25namespace builder {
26namespace basic {
27namespace impl {
28
29template <typename T>
30BSONCXX_INLINE detail::requires_t<void, detail::is_invocable<T, sub_document>> //
31generic_append(core* core, T&& func) {
32 core->open_document();
33 detail::invoke(std::forward<T>(func), sub_document(core));
34 core->close_document();
35}
36
37template <typename T, typename Placeholder = void> // placeholder 'void' for VS2015 compat
38BSONCXX_INLINE detail::requires_t<void, detail::is_invocable<T, sub_array>> //
39generic_append(core* core, T&& func) {
40 core->open_array();
41 detail::invoke(std::forward<T>(func), sub_array(core));
42 core->close_array();
43}
44
45template <typename T, typename = void, typename = void>
46BSONCXX_INLINE detail::requires_not_t<void, //
47 detail::is_invocable<T, sub_document>,
48 detail::is_invocable<T, sub_array>>
49generic_append(core* core, T&& t) {
50 core->append(std::forward<T>(t));
51}
52
53template <typename T>
54BSONCXX_INLINE void value_append(core* core, T&& t) {
55 generic_append(core, std::forward<T>(t));
56}
57
58} // namespace impl
59} // namespace basic
60} // namespace builder
61} // namespace v_noabi
62} // namespace bsoncxx
63
64#include <bsoncxx/config/postlude.hpp>
The top-level namespace for bsoncxx library entities.
Definition element-fwd.hpp:19