summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/local_function/example/const_block.hpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/local_function/example/const_block.hpp
parentInitial commit. (diff)
downloadceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz
ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/boost/libs/local_function/example/const_block.hpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/boost/libs/local_function/example/const_block.hpp b/src/boost/libs/local_function/example/const_block.hpp
new file mode 100644
index 000000000..904273410
--- /dev/null
+++ b/src/boost/libs/local_function/example/const_block.hpp
@@ -0,0 +1,58 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#ifndef CONST_BLOCK_HPP_
+#define CONST_BLOCK_HPP_
+
+#include <boost/local_function.hpp>
+#include <boost/local_function/detail/preprocessor/void_list.hpp>
+#include <boost/local_function/detail/preprocessor/line_counter.hpp>
+#include <boost/preprocessor/list/for_each_i.hpp>
+#include <boost/preprocessor/list/adt.hpp>
+#include <boost/preprocessor/tuple/eat.hpp>
+#include <boost/preprocessor/punctuation/comma_if.hpp>
+#include <boost/preprocessor/control/iif.hpp>
+#include <boost/preprocessor/cat.hpp>
+
+// PRIVATE //
+
+#define CONST_BLOCK_BIND_(r, unused, i, var) \
+ BOOST_PP_COMMA_IF(i) const bind& var
+
+//[const_block_macro
+#define CONST_BLOCK_(variables) \
+ void BOOST_LOCAL_FUNCTION( \
+ BOOST_PP_IIF(BOOST_PP_LIST_IS_NIL(variables), \
+ void BOOST_PP_TUPLE_EAT(3) \
+ , \
+ BOOST_PP_LIST_FOR_EACH_I \
+ )(CONST_BLOCK_BIND_, ~, variables) \
+ )
+//]
+
+//[const_block_end_macro
+#define CONST_BLOCK_END_(id) \
+ BOOST_LOCAL_FUNCTION_NAME(BOOST_PP_CAT(const_block_, id)) \
+ BOOST_PP_CAT(const_block_, id)(); /* call local function immediately */
+//]
+
+// PUBLIC //
+
+// Arguments `void | var1, var2, ... | (var1) (var2) ...`.
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# define CONST_BLOCK(void_or_seq) \
+ CONST_BLOCK_(BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(void_or_seq))
+#else
+# define CONST_BLOCK(...) \
+ CONST_BLOCK_(BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(__VA_ARGS__))
+#endif
+
+#define CONST_BLOCK_END \
+ CONST_BLOCK_END_(BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER)
+
+#endif // #include guard
+