Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@

#include <bsoncxx/config/prelude.hpp>

namespace bsoncxx {
namespace detail {

template <typename T>
using is_bson_view_compatible =
detail::conjunction<std::is_constructible<bsoncxx::v_noabi::types::bson_value::view, T>,
detail::negation<detail::disjunction<
detail::is_alike<T, bsoncxx::v_noabi::types::bson_value::view>,
detail::is_alike<T, bsoncxx::v_noabi::types::bson_value::value>>>>;

} // namespace detail
} // namespace bsoncxx

namespace bsoncxx {
namespace v_noabi {
namespace types {
Expand Down Expand Up @@ -303,15 +316,6 @@ class view {
};
};

template <typename T>
using is_bson_view_compatible = detail::conjunction<
std::is_constructible<bson_value::view, T>,
detail::negation<detail::disjunction<detail::is_alike<T, bson_value::view>,
detail::is_alike<T, bson_value::value>>>>;

template <typename T>
using not_view = is_bson_view_compatible<T>;

///
/// Compares a view with a type representable as a view.
///
Expand All @@ -322,28 +326,28 @@ using not_view = is_bson_view_compatible<T>;

/// @relatesalso bsoncxx::v_noabi::types::bson_value::view
template <typename T>
detail::requires_t<bool, is_bson_view_compatible<T>> //
detail::requires_t<bool, detail::is_bson_view_compatible<T>> //
operator==(const bson_value::view& lhs, T&& rhs) {
return lhs == bson_value::view{std::forward<T>(rhs)};
}

/// @relatesalso bsoncxx::v_noabi::types::bson_value::view
template <typename T>
detail::requires_t<bool, is_bson_view_compatible<T>> //
detail::requires_t<bool, detail::is_bson_view_compatible<T>> //
operator==(T&& lhs, const bson_value::view& rhs) {
return bson_value::view{std::forward<T>(lhs)} == rhs;
}

/// @relatesalso bsoncxx::v_noabi::types::bson_value::view
template <typename T>
detail::requires_t<bool, is_bson_view_compatible<T>> //
detail::requires_t<bool, detail::is_bson_view_compatible<T>> //
operator!=(const bson_value::view& lhs, T&& rhs) {
return lhs != bson_value::view{std::forward<T>(rhs)};
}

/// @relatesalso bsoncxx::v_noabi::types::bson_value::view
template <typename T>
detail::requires_t<bool, is_bson_view_compatible<T>> //
detail::requires_t<bool, detail::is_bson_view_compatible<T>> //
operator!=(T&& lhs, const bson_value::view& rhs) {
return bson_value::view{std::forward<T>(lhs)} != rhs;
}
Expand Down