]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/contract/test/call_if/no_equal_call_if.cpp
2 // Copyright (C) 2008-2018 Lorenzo Caminiti
3 // Distributed under the Boost Software License, Version 1.0 (see accompanying
4 // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
5 // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
7 // Test assertions skipped when operations to check them missing (e.g., `==`).
9 // C++17 warning from Boost.Bind.
10 #define _SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING
12 #include <boost/contract/function.hpp>
13 #include <boost/contract/check.hpp>
14 #include <boost/contract/assert.hpp>
15 #include <boost/contract/call_if.hpp>
16 #include <boost/bind.hpp>
17 #include <boost/type_traits/has_equal_to.hpp>
18 #include <boost/detail/lightweight_test.hpp>
25 void push_back(std::vector
<T
>& vect
, T
const& value
) {
26 boost::contract::check c
= boost::contract::function()
28 BOOST_CONTRACT_ASSERT(
29 boost::contract::call_if
<boost::has_equal_to
<T
> >(
30 boost::bind(std::equal_to
<T
>(), boost::cref(vect
.back()),
32 // Explicit bool return and [&] needed for MSVC10 lambdas.
33 ).else_([&] () -> bool { ++equal_skips
; return true; })
37 vect
.push_back(value
);
40 struct j
{ // Type without operator==.
41 explicit j(int /* i */) {}
48 BOOST_TEST_EQ(equal_skips
, 0);
51 #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS
62 BOOST_TEST_EQ(equal_skips
, cnt
);
64 return boost::report_errors();