]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/test/x3/eps.cpp
b46131e92361468f56a55740366868fabc417bad
[ceph.git] / ceph / src / boost / libs / spirit / test / x3 / eps.cpp
1 /*=============================================================================
2 Copyright (c) 2001-2015 Joel de Guzman
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 =============================================================================*/
7 #include <boost/spirit/home/x3.hpp>
8
9 #include <iostream>
10 #include "test.hpp"
11
12 int
13 main()
14 {
15 using spirit_test::test;
16 using boost::spirit::x3::eps;
17 using boost::spirit::x3::unused_type;
18
19 {
20 BOOST_SPIRIT_ASSERT_CONSTEXPR_CTORS(eps);
21 BOOST_TEST((test("", eps)));
22 BOOST_TEST((test("xxx", eps, false)));
23 //~ BOOST_TEST((!test("", !eps))); // not predicate $$$ Implement me! $$$
24 }
25
26 { // test non-lazy semantic predicate
27
28 BOOST_SPIRIT_ASSERT_CONSTEXPR_CTORS(eps(true));
29 BOOST_TEST((test("", eps(true))));
30 BOOST_TEST((!test("", eps(false))));
31 BOOST_TEST((test("", !eps(false))));
32 }
33
34 { // test lazy semantic predicate
35
36 auto true_ = [](unused_type) { return true; };
37 auto false_ = [](unused_type) { return false; };
38
39 // cannot use lambda in constant expression before C++17
40 BOOST_SPIRIT_ASSERT_CONSTEXPR_CTORS(eps(std::true_type{}));
41 BOOST_TEST((test("", eps(true_))));
42 BOOST_TEST((!test("", eps(false_))));
43 BOOST_TEST((test("", !eps(false_))));
44 }
45
46 return boost::report_errors();
47 }