summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/flyweight/test/test_init.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/flyweight/test/test_init.cpp
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/flyweight/test/test_init.cpp')
-rw-r--r--src/boost/libs/flyweight/test/test_init.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/boost/libs/flyweight/test/test_init.cpp b/src/boost/libs/flyweight/test/test_init.cpp
new file mode 100644
index 00000000..5421b808
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_init.cpp
@@ -0,0 +1,49 @@
+/* Boost.Flyweight test of static data initialization facilities.
+ *
+ * Copyright 2006-2019 Joaquin M Lopez Munoz.
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#include "test_init.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/flyweight.hpp>
+
+using namespace boost::flyweights;
+
+template<bool* pmark,typename Entry,typename Value>
+struct marked_hashed_factory_class:hashed_factory_class<Entry,Value>
+{
+ marked_hashed_factory_class(){*pmark=true;}
+};
+
+template<bool* pmark>
+struct marked_hashed_factory:factory_marker
+{
+ template<typename Entry,typename Value>
+ struct apply
+ {
+ typedef marked_hashed_factory_class<pmark,Entry,Value> type;
+ };
+};
+
+namespace boost_flyweight_test{
+
+bool mark1=false;
+bool init1=flyweight<int,marked_hashed_factory<&mark1> >::init();
+
+bool mark2=false;
+flyweight<int,marked_hashed_factory<&mark2> >::initializer init2;
+
+}
+
+void test_init()
+{
+ BOOST_TEST(boost_flyweight_test::mark1);
+ BOOST_TEST(boost_flyweight_test::mark2);
+}