]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/spirit/test/x3/rule3.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / spirit / test / x3 / rule3.cpp
index ac7a32dd89caae10c039e5cee68f0449f3058f60..420146c0458ec1ee0a6acae781fd0f9bd9dc804a 100644 (file)
@@ -5,9 +5,6 @@
     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 =============================================================================*/
 
-// this file deliberately contains non-ascii characters
-// boostinspect:noascii
-
 #include <boost/detail/lightweight_test.hpp>
 #include <boost/spirit/home/x3.hpp>
 #include <boost/fusion/include/std_pair.hpp>
@@ -28,6 +25,29 @@ struct f
     }
 };
 
+
+struct stationary : boost::noncopyable
+{
+    explicit stationary(int i) : val{i} {}
+    stationary& operator=(int i) { val = i; return *this; }
+
+    int val;
+};
+
+
+namespace check_stationary {
+
+boost::spirit::x3::rule<class a_r, stationary> const a;
+boost::spirit::x3::rule<class b_r, stationary> const b;
+
+auto const a_def = '{' >> boost::spirit::x3::int_ >> '}';
+auto const b_def = a;
+
+BOOST_SPIRIT_DEFINE(a, b)
+
+}
+
+
 int main()
 {
     using spirit_test::test_attr;
@@ -35,8 +55,9 @@ int main()
 
     using namespace boost::spirit::x3::ascii;
     using boost::spirit::x3::rule;
-    using boost::spirit::x3::int_;
     using boost::spirit::x3::lit;
+    using boost::spirit::x3::eps;
+    using boost::spirit::x3::unused_type;
 
 
     { // synth attribute value-init
@@ -69,5 +90,20 @@ int main()
         BOOST_TEST(s == "abcdef");
     }
 
+    {
+        auto r = rule<class r, int>{} = eps[([] (auto& ctx) {
+            using boost::spirit::x3::_val;
+            static_assert(std::is_same<std::decay_t<decltype(_val(ctx))>, unused_type>::value,
+                "Attribute must not be synthesized");
+        })];
+        BOOST_TEST(test("", r));
+    }
+
+    { // ensure no unneded synthesization, copying and moving occured
+        stationary st { 0 };
+        BOOST_TEST(test_attr("{42}", check_stationary::b, st));
+        BOOST_TEST_EQ(st.val, 42);
+    }
+
     return boost::report_errors();
 }