summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/flyweight/test
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/flyweight/test
parentInitial commit. (diff)
downloadceph-upstream/16.2.11+ds.tar.xz
ceph-upstream/16.2.11+ds.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 'src/boost/libs/flyweight/test')
-rw-r--r--src/boost/libs/flyweight/test/Jamfile.v236
-rw-r--r--src/boost/libs/flyweight/test/heavy_objects.hpp106
-rw-r--r--src/boost/libs/flyweight/test/intermod_holder_dll.cpp17
-rw-r--r--src/boost/libs/flyweight/test/intermod_holder_dll.hpp41
-rw-r--r--src/boost/libs/flyweight/test/test_all_main.cpp38
-rw-r--r--src/boost/libs/flyweight/test/test_assoc_cont_fact_main.cpp18
-rw-r--r--src/boost/libs/flyweight/test/test_assoc_cont_factory.cpp91
-rw-r--r--src/boost/libs/flyweight/test/test_assoc_cont_factory.hpp11
-rw-r--r--src/boost/libs/flyweight/test/test_basic.cpp68
-rw-r--r--src/boost/libs/flyweight/test/test_basic.hpp11
-rw-r--r--src/boost/libs/flyweight/test/test_basic_main.cpp18
-rw-r--r--src/boost/libs/flyweight/test/test_basic_template.hpp304
-rw-r--r--src/boost/libs/flyweight/test/test_custom_factory.cpp111
-rw-r--r--src/boost/libs/flyweight/test/test_custom_factory.hpp11
-rw-r--r--src/boost/libs/flyweight/test/test_custom_factory_main.cpp18
-rw-r--r--src/boost/libs/flyweight/test/test_init.cpp49
-rw-r--r--src/boost/libs/flyweight/test/test_init.hpp11
-rw-r--r--src/boost/libs/flyweight/test/test_init_main.cpp18
-rw-r--r--src/boost/libs/flyweight/test/test_intermod_holder.cpp34
-rw-r--r--src/boost/libs/flyweight/test/test_intermod_holder.hpp11
-rw-r--r--src/boost/libs/flyweight/test/test_intermod_holder_main.cpp18
-rw-r--r--src/boost/libs/flyweight/test/test_multictor.cpp191
-rw-r--r--src/boost/libs/flyweight/test/test_multictor.hpp11
-rw-r--r--src/boost/libs/flyweight/test/test_multictor_main.cpp18
-rw-r--r--src/boost/libs/flyweight/test/test_no_locking.cpp35
-rw-r--r--src/boost/libs/flyweight/test/test_no_locking.hpp11
-rw-r--r--src/boost/libs/flyweight/test/test_no_locking_main.cpp18
-rw-r--r--src/boost/libs/flyweight/test/test_no_tracking.cpp35
-rw-r--r--src/boost/libs/flyweight/test/test_no_tracking.hpp11
-rw-r--r--src/boost/libs/flyweight/test/test_no_tracking_main.cpp18
-rw-r--r--src/boost/libs/flyweight/test/test_serialization.cpp31
-rw-r--r--src/boost/libs/flyweight/test/test_serialization.hpp11
-rw-r--r--src/boost/libs/flyweight/test/test_serialization_main.cpp18
-rw-r--r--src/boost/libs/flyweight/test/test_serialization_template.hpp128
-rw-r--r--src/boost/libs/flyweight/test/test_set_factory.cpp72
-rw-r--r--src/boost/libs/flyweight/test/test_set_factory.hpp11
-rw-r--r--src/boost/libs/flyweight/test/test_set_factory_main.cpp18
37 files changed, 1677 insertions, 0 deletions
diff --git a/src/boost/libs/flyweight/test/Jamfile.v2 b/src/boost/libs/flyweight/test/Jamfile.v2
new file mode 100644
index 000000000..d43d08214
--- /dev/null
+++ b/src/boost/libs/flyweight/test/Jamfile.v2
@@ -0,0 +1,36 @@
+# Boost.Flyweight tests Jamfile
+#
+# Copyright 2006-2014 Joaquín M López Muñoz.
+# 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.
+
+project
+ : requirements
+ <os>LINUX:<threading>multi
+ ;
+
+test-suite "flyweight" :
+ [ run test_assoc_cont_factory.cpp test_assoc_cont_fact_main.cpp ]
+ [ run test_basic.cpp test_basic_main.cpp ]
+ [ run test_custom_factory.cpp test_custom_factory_main.cpp ]
+ [ run test_init.cpp test_init_main.cpp ]
+ [ run test_intermod_holder.cpp test_intermod_holder_main.cpp
+ intermod_holder_dll
+ : # command line
+ : # input files
+ : # requirements
+ <threading>multi ]
+ [ run test_multictor.cpp test_multictor_main.cpp ]
+ [ run test_no_locking.cpp test_no_locking_main.cpp ]
+ [ run test_no_tracking.cpp test_no_tracking_main.cpp ]
+ [ run test_serialization.cpp test_serialization_main.cpp
+ /boost/serialization//boost_serialization/<link>static ]
+ [ run test_set_factory.cpp test_set_factory_main.cpp ]
+ ;
+
+lib intermod_holder_dll : intermod_holder_dll.cpp :
+ <link>shared
+ <define>BOOST_FLYWEIGHT_TEST_INTERMOD_HOLDER_DLL_SOURCE=1 ;
diff --git a/src/boost/libs/flyweight/test/heavy_objects.hpp b/src/boost/libs/flyweight/test/heavy_objects.hpp
new file mode 100644
index 000000000..142e96b7c
--- /dev/null
+++ b/src/boost/libs/flyweight/test/heavy_objects.hpp
@@ -0,0 +1,106 @@
+/* Classes for Boost.Flyweight key-value tests.
+ *
+ * Copyright 2006-2014 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.
+ */
+
+#ifndef BOOST_FLYWEIGHT_TEST_HEAVY_OBJECTS_HPP
+#define BOOST_FLYWEIGHT_TEST_HEAVY_OBJECTS_HPP
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/noncopyable.hpp>
+#include <iosfwd>
+#include <string>
+
+struct texture
+{
+ texture(const std::string& str_=""):str(str_){}
+
+ friend bool operator==(
+ const texture& x,const texture& y){return x.str==y.str;}
+ friend bool operator< (
+ const texture& x,const texture& y){return x.str< y.str;}
+ friend bool operator!=(
+ const texture& x,const texture& y){return x.str!=y.str;}
+ friend bool operator> (
+ const texture& x,const texture& y){return x.str> y.str;}
+ friend bool operator>=(
+ const texture& x,const texture& y){return x.str>=y.str;}
+ friend bool operator<=(
+ const texture& x,const texture& y){return x.str<=y.str;}
+
+ friend std::ostream& operator<<(std::ostream& os,const texture& x)
+ {
+ return os<<x.str;
+ }
+
+ friend std::istream& operator>>(std::istream& is,texture& x)
+ {
+ return is>>x.str;
+ }
+
+ std::string str;
+};
+
+struct from_texture_to_string
+{
+ const std::string& operator()(const texture& x)const{return x.str;}
+};
+
+struct factorization:private boost::noncopyable
+{
+ factorization(int n_=0):n(n_){}
+
+ friend bool operator==(
+ const factorization& x,const factorization& y){return x.n==y.n;}
+ friend bool operator< (
+ const factorization& x,const factorization& y){return x.n< y.n;}
+ friend bool operator!=(
+ const factorization& x,const factorization& y){return x.n!=y.n;}
+ friend bool operator> (
+ const factorization& x,const factorization& y){return x.n> y.n;}
+ friend bool operator>=(
+ const factorization& x,const factorization& y){return x.n>=y.n;}
+ friend bool operator<=(
+ const factorization& x,const factorization& y){return x.n<=y.n;}
+
+ friend std::ostream& operator<<(std::ostream& os,const factorization& x)
+ {
+ return os<<x.n;
+ }
+
+ friend std::istream& operator>>(std::istream& is,factorization& x)
+ {
+ return is>>x.n;
+ }
+
+ int n;
+};
+
+#if !defined(BOOST_NO_EXCEPTIONS)
+struct throwing_value_exception{};
+
+struct throwing_value
+{
+ throwing_value():n(0){}
+ throwing_value(const throwing_value&){throw throwing_value_exception();}
+ throwing_value(int){throw throwing_value_exception();}
+
+ int n;
+};
+
+struct from_throwing_value_to_int
+{
+ const int& operator()(const throwing_value& x)const{return x.n;}
+};
+#endif
+
+#endif
diff --git a/src/boost/libs/flyweight/test/intermod_holder_dll.cpp b/src/boost/libs/flyweight/test/intermod_holder_dll.cpp
new file mode 100644
index 000000000..098bca322
--- /dev/null
+++ b/src/boost/libs/flyweight/test/intermod_holder_dll.cpp
@@ -0,0 +1,17 @@
+/* Boost.Flyweight test of intermodule_holder.
+ *
+ * Copyright 2006-2008 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 "intermod_holder_dll.hpp"
+
+intermodule_flyweight_string create_intermodule_flyweight_string(
+ const std::string& str)
+{
+ return intermodule_flyweight_string(str);
+}
diff --git a/src/boost/libs/flyweight/test/intermod_holder_dll.hpp b/src/boost/libs/flyweight/test/intermod_holder_dll.hpp
new file mode 100644
index 000000000..4df7ff8c2
--- /dev/null
+++ b/src/boost/libs/flyweight/test/intermod_holder_dll.hpp
@@ -0,0 +1,41 @@
+/* Boost.Flyweight test of intermodule_holder.
+ *
+ * Copyright 2006-2018 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.
+ */
+
+#ifndef BOOST_FLYWEIGHT_TEST_INTERMOD_HOLDER_DLL_HPP
+#define BOOST_FLYWEIGHT_TEST_INTERMOD_HOLDER_DLL_HPP
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/flyweight.hpp>
+#include <boost/flyweight/hashed_factory.hpp>
+#include <boost/flyweight/intermodule_holder.hpp>
+#include <boost/flyweight/refcounted.hpp>
+#include <boost/flyweight/simple_locking.hpp>
+#include <string>
+
+#ifdef BOOST_FLYWEIGHT_TEST_INTERMOD_HOLDER_DLL_SOURCE
+#define BOOST_FLYWEIGHT_DLL_DECL BOOST_SYMBOL_EXPORT
+#else
+#define BOOST_FLYWEIGHT_DLL_DECL BOOST_SYMBOL_IMPORT
+#endif
+
+typedef boost::flyweights::flyweight<
+ std::string,
+ boost::flyweights::intermodule_holder> intermodule_flyweight_string;
+
+BOOST_FLYWEIGHT_DLL_DECL intermodule_flyweight_string
+create_intermodule_flyweight_string(const std::string&);
+
+#undef BOOST_FLYWEIGHT_DLL_DECL
+
+#endif
diff --git a/src/boost/libs/flyweight/test/test_all_main.cpp b/src/boost/libs/flyweight/test/test_all_main.cpp
new file mode 100644
index 000000000..737f95a8f
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_all_main.cpp
@@ -0,0 +1,38 @@
+/* Boost.Flyweight test suite.
+ *
+ * Copyright 2006-2014 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 <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/lightweight_test.hpp>
+#include "test_assoc_cont_factory.hpp"
+#include "test_basic.hpp"
+#include "test_custom_factory.hpp"
+#include "test_intermod_holder.hpp"
+#include "test_init.hpp"
+#include "test_multictor.hpp"
+#include "test_no_locking.hpp"
+#include "test_no_tracking.hpp"
+#include "test_serialization.hpp"
+#include "test_set_factory.hpp"
+
+int main()
+{
+ test_assoc_container_factory();
+ test_basic();
+ test_custom_factory();
+ test_init();
+ test_intermodule_holder();
+ test_multictor();
+ test_no_locking();
+ test_no_tracking();
+ test_serialization();
+ test_set_factory();
+
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/flyweight/test/test_assoc_cont_fact_main.cpp b/src/boost/libs/flyweight/test/test_assoc_cont_fact_main.cpp
new file mode 100644
index 000000000..1b3e7b71d
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_assoc_cont_fact_main.cpp
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of assoc_container_factory.
+ *
+ * Copyright 2006-2008 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 <boost/detail/lightweight_test.hpp>
+#include "test_assoc_cont_factory.hpp"
+
+int main()
+{
+ test_assoc_container_factory();
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/flyweight/test/test_assoc_cont_factory.cpp b/src/boost/libs/flyweight/test/test_assoc_cont_factory.cpp
new file mode 100644
index 000000000..078ff4aec
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_assoc_cont_factory.cpp
@@ -0,0 +1,91 @@
+/* Boost.Flyweight test of assoc_container_factory.
+ *
+ * Copyright 2006-2018 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_assoc_cont_factory.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/assoc_container_factory.hpp>
+#include <boost/flyweight/detail/is_placeholder_expr.hpp>
+#include <boost/flyweight/flyweight.hpp>
+#include <boost/flyweight/refcounted.hpp>
+#include <boost/flyweight/simple_locking.hpp>
+#include <boost/flyweight/static_holder.hpp>
+#include <boost/mpl/if.hpp>
+#include <functional>
+#include <set>
+#include "test_basic_template.hpp"
+
+using namespace boost::flyweights;
+
+struct reverse_set_specifier
+{
+ template<typename Entry,typename Key>
+ struct apply
+ {
+ typedef std::set<Entry,std::greater<Key> > type;
+ };
+};
+
+struct assoc_container_factory_flyweight_specifier1
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<
+ T,
+ assoc_container_factory<reverse_set_specifier>
+ > type;
+ };
+};
+
+/* flyweight<..., assoc_container_factory_class<std::set<...> >, ...> pulls
+ * the type std::set<...> in as part of its associated ADL set and causes it
+ * to be instantiated when doing any unqualified function call like, for
+ * instance, comparing flyweights for equality, which can trigger a static
+ * assertion in concept-checked STL implementations when std::set<...> is an
+ * MPL placeholder expression. We avoid this mess with protected_set<...>.
+ */
+
+struct protected_set_empty_base{};
+
+template<typename K,typename C,typename A>
+struct protected_set:
+ boost::mpl::if_c<
+ boost::flyweights::detail::is_placeholder_expression<
+ protected_set<K,C,A>
+ >::value,
+ protected_set_empty_base,
+ std::set<K,C,A>
+ >::type
+{};
+
+struct assoc_container_factory_flyweight_specifier2
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<
+ T,
+ assoc_container_factory_class<
+ protected_set<
+ boost::mpl::_1,
+ std::greater<boost::mpl::_2>,
+ std::allocator<boost::mpl::_1>
+ >
+ >
+ > type;
+ };
+};
+
+void test_assoc_container_factory()
+{
+ test_basic_template<assoc_container_factory_flyweight_specifier1>();
+ test_basic_template<assoc_container_factory_flyweight_specifier2>();
+}
diff --git a/src/boost/libs/flyweight/test/test_assoc_cont_factory.hpp b/src/boost/libs/flyweight/test/test_assoc_cont_factory.hpp
new file mode 100644
index 000000000..e9aa9313d
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_assoc_cont_factory.hpp
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of assoc_container_factory.
+ *
+ * Copyright 2006-2008 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.
+ */
+
+void test_assoc_container_factory();
diff --git a/src/boost/libs/flyweight/test/test_basic.cpp b/src/boost/libs/flyweight/test/test_basic.cpp
new file mode 100644
index 000000000..53285ec22
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_basic.cpp
@@ -0,0 +1,68 @@
+/* Boost.Flyweight basic test.
+ *
+ * Copyright 2006-2008 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_basic.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight.hpp>
+#include "test_basic_template.hpp"
+
+using namespace boost::flyweights;
+
+struct basic_flyweight_specifier1
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<T> type;
+ };
+};
+
+struct basic_flyweight_specifier2
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<
+ T,tag<int>,
+ static_holder_class<boost::mpl::_1>,
+ hashed_factory_class<
+ boost::mpl::_1,boost::mpl::_2,
+ boost::hash<boost::mpl::_2>,std::equal_to<boost::mpl::_2>,
+ std::allocator<boost::mpl::_1>
+ >,
+ simple_locking,
+ refcounted
+ > type;
+ };
+};
+
+struct basic_flyweight_specifier3
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<
+ T,
+ hashed_factory<
+ boost::hash<boost::mpl::_2>,std::equal_to<boost::mpl::_2>,
+ std::allocator<boost::mpl::_1>
+ >,
+ tag<int>
+ > type;
+ };
+};
+
+void test_basic()
+{
+ test_basic_template<basic_flyweight_specifier1>();
+ test_basic_template<basic_flyweight_specifier2>();
+ test_basic_template<basic_flyweight_specifier3>();
+}
diff --git a/src/boost/libs/flyweight/test/test_basic.hpp b/src/boost/libs/flyweight/test/test_basic.hpp
new file mode 100644
index 000000000..d7d86d5f1
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_basic.hpp
@@ -0,0 +1,11 @@
+/* Boost.Flyweight basic test.
+ *
+ * Copyright 2006-2008 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.
+ */
+
+void test_basic();
diff --git a/src/boost/libs/flyweight/test/test_basic_main.cpp b/src/boost/libs/flyweight/test/test_basic_main.cpp
new file mode 100644
index 000000000..b2508d85c
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_basic_main.cpp
@@ -0,0 +1,18 @@
+/* Boost.Flyweight basic test.
+ *
+ * Copyright 2006-2008 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 <boost/detail/lightweight_test.hpp>
+#include "test_basic.hpp"
+
+int main()
+{
+ test_basic();
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/flyweight/test/test_basic_template.hpp b/src/boost/libs/flyweight/test/test_basic_template.hpp
new file mode 100644
index 000000000..61b462be4
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_basic_template.hpp
@@ -0,0 +1,304 @@
+/* Boost.Flyweight basic test template.
+ *
+ * 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.
+ */
+
+#ifndef BOOST_FLYWEIGHT_TEST_BASIC_TEMPLATE_HPP
+#define BOOST_FLYWEIGHT_TEST_BASIC_TEMPLATE_HPP
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/flyweight/key_value.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/utility/value_init.hpp>
+#include <string>
+#include <sstream>
+#include "heavy_objects.hpp"
+
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+#include <utility>
+#endif
+
+#if !defined(BOOST_FLYWEIGHT_DISABLE_HASH_SUPPORT)
+#include <boost/functional/hash.hpp>
+
+#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
+#include <functional>
+#endif
+#endif
+
+#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
+
+template<typename Flyweight,typename ForwardIterator>
+void test_basic_template(
+ ForwardIterator first,ForwardIterator last
+ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight))
+{
+ typedef typename Flyweight::value_type value_type;
+
+ ForwardIterator it;
+
+ for(it=first;it!=last;++it){
+ /* construct/copy/destroy */
+
+ Flyweight f1(*it);
+ Flyweight f2;
+ Flyweight c1(f1);
+ const Flyweight c2(static_cast<const Flyweight&>(f2));
+ value_type v1(*it);
+ boost::value_initialized<value_type> v2;
+ BOOST_TEST(f1.get_key()==*it);
+ BOOST_TEST((f1==f2)==(f1.get()==v2.data()));
+ BOOST_TEST(f1==c1);
+ BOOST_TEST(f2==c2);
+
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+ Flyweight cr1(std::move(c1));
+ Flyweight cr2(std::move(c2));
+ BOOST_TEST(f1==cr1);
+ BOOST_TEST(f2==cr2);
+#endif
+
+#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
+ /* testcase for https://svn.boost.org/trac/boost/ticket/10439 */
+
+ Flyweight f3={};
+ BOOST_TEST(f3==f2);
+#endif
+
+ f1=((void)0,f1); /* self assignment warning */
+ BOOST_TEST(f1==f1);
+
+ c1=f2;
+ BOOST_TEST(c1==f2);
+
+ c1=f1;
+ BOOST_TEST(c1==f1);
+
+ /* convertibility to underlying type */
+
+ BOOST_TEST(f1.get()==v1);
+
+ /* identity of reference */
+
+ BOOST_TEST(&f1.get()==&c1.get());
+
+ /* modifiers */
+
+ f1.swap(f1);
+ BOOST_TEST(f1==c1);
+
+ f1.swap(f2);
+ BOOST_TEST(f1==c2);
+ BOOST_TEST(f2==c1);
+
+ boost::flyweights::swap(f1,f2);
+ BOOST_TEST(f1==c1);
+ BOOST_TEST(f2==c2);
+
+ /* specialized algorithms */
+
+ std::ostringstream oss1;
+ oss1<<f1;
+ std::ostringstream oss2;
+ oss2<<f1.get();
+ BOOST_TEST(oss1.str()==oss2.str());
+
+#if !defined(BOOST_FLYWEIGHT_DISABLE_HASH_SUPPORT)
+
+ /* hash support */
+
+ BOOST_TEST(boost::hash<Flyweight>()(f1)==boost::hash<Flyweight>()(c1));
+ BOOST_TEST(boost::hash<Flyweight>()(f1)==
+ boost::hash<const value_type*>()(&f1.get()));
+
+#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
+ BOOST_TEST(std::hash<Flyweight>()(f1)==std::hash<Flyweight>()(c1));
+ BOOST_TEST(std::hash<Flyweight>()(f1)==
+ std::hash<const value_type*>()(&f1.get()));
+#endif
+#endif
+ }
+}
+
+template<typename Flyweight,typename ForwardIterator>
+void test_basic_with_assign_template(
+ ForwardIterator first,ForwardIterator last
+ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight))
+{
+ typedef typename Flyweight::value_type value_type;
+
+ ForwardIterator it;
+
+ test_basic_template<Flyweight>(first,last);
+
+ for(it=first;it!=last;++it){
+ /* value construction */
+
+ value_type v(*it);
+ Flyweight f1(v);
+ Flyweight f2(f1.get());
+ BOOST_TEST(f1.get()==v);
+ BOOST_TEST(f2.get()==v);
+ BOOST_TEST(f1==f2);
+
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+ value_type v1(v);
+ const value_type v2(v);
+ Flyweight fr1(std::move(v1));
+ Flyweight fr2(std::move(v2));
+ BOOST_TEST(fr1==v);
+ BOOST_TEST(fr2==v);
+#endif
+
+ /* value assignment */
+
+ Flyweight f3,f4;
+ f3=v;
+ f4=f1.get();
+ BOOST_TEST(f2.get()==v);
+ BOOST_TEST(f3.get()==v);
+ BOOST_TEST(f2==f3);
+
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+ Flyweight fr3;
+ fr3=value_type(*it);
+ BOOST_TEST(fr3.get()==value_type(*it));
+#endif
+
+ /* specialized algorithms */
+
+ std::ostringstream oss1;
+ oss1<<f1;
+ std::istringstream iss1(oss1.str());
+ Flyweight f5;
+ iss1>>f5;
+ BOOST_TEST(f5==f1);
+ }
+}
+
+template<
+ typename Flyweight1,typename Flyweight2,
+ typename ForwardIterator1,typename ForwardIterator2
+>
+void test_basic_comparison_template(
+ ForwardIterator1 first1,ForwardIterator1 last1,
+ ForwardIterator2 first2
+ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight1)
+ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight2))
+{
+ typedef typename Flyweight1::value_type value_type1;
+ typedef typename Flyweight2::value_type value_type2;
+
+ for(;first1!=last1;++first1,++first2){
+ value_type1 v1=value_type1(*first1);
+ value_type2 v2=value_type2(*first2);
+ Flyweight1 f1(v1);
+ Flyweight2 f2(v2);
+
+ BOOST_TEST((f1==f2)==(f1.get()==v2));
+ BOOST_TEST((f1< f2)==(f1.get()< v2));
+ BOOST_TEST((f1!=f2)==(f1.get()!=v2));
+ BOOST_TEST((f1> f2)==(f1.get()> v2));
+ BOOST_TEST((f1>=f2)==(f1.get()>=v2));
+ BOOST_TEST((f1<=f2)==(f1.get()<=v2));
+
+#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
+ BOOST_TEST((f1==v2)==(f1.get()==v2));
+ BOOST_TEST((f1< v2)==(f1.get()< v2));
+ BOOST_TEST((f1!=v2)==(f1.get()!=v2));
+ BOOST_TEST((f1> v2)==(f1.get()> v2));
+ BOOST_TEST((f1>=v2)==(f1.get()>=v2));
+ BOOST_TEST((f1<=v2)==(f1.get()<=v2));
+
+ BOOST_TEST((v1==f2)==(f1.get()==v2));
+ BOOST_TEST((v1< f2)==(f1.get()< v2));
+ BOOST_TEST((v1!=f2)==(f1.get()!=v2));
+ BOOST_TEST((v1> f2)==(f1.get()> v2));
+ BOOST_TEST((v1>=f2)==(f1.get()>=v2));
+ BOOST_TEST((v1<=f2)==(f1.get()<=v2));
+#endif
+
+ }
+}
+
+template<typename FlyweightSpecifier>
+void test_basic_template(BOOST_EXPLICIT_TEMPLATE_TYPE(FlyweightSpecifier))
+{
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,int
+ >::type int_flyweight;
+
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,std::string
+ >::type string_flyweight;
+
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,char
+ >::type char_flyweight;
+
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,
+ boost::flyweights::key_value<std::string,texture,from_texture_to_string>
+ >::type texture_flyweight;
+
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,
+ boost::flyweights::key_value<int,factorization>
+ >::type factorization_flyweight;
+
+ int ints[]={0,1,1,0,1,2,3,4,3,4,0,0};
+ test_basic_with_assign_template<int_flyweight>(
+ &ints[0],&ints[0]+LENGTHOF(ints));
+
+ const char* words[]={"hello","boost","flyweight","boost","bye","c++","c++"};
+ test_basic_with_assign_template<string_flyweight>(
+ &words[0],&words[0]+LENGTHOF(words));
+
+ const char* textures[]={"wood","grass","sand","granite","terracotta"};
+ test_basic_with_assign_template<texture_flyweight>(
+ &textures[0],&textures[0]+LENGTHOF(textures));
+
+ int factorizations[]={1098,102387,90846,2223978};
+ test_basic_template<factorization_flyweight>(
+ &factorizations[0],&factorizations[0]+LENGTHOF(factorizations));
+
+ char chars[]={0,2,4,5,1,1,1,3,4,1,1,0};
+ test_basic_comparison_template<int_flyweight,char_flyweight>(
+ &ints[0],&ints[0]+LENGTHOF(ints),&chars[0]);
+
+ test_basic_comparison_template<string_flyweight,string_flyweight>(
+ &words[0],&words[0]+LENGTHOF(words)-1,&words[1]);
+
+ test_basic_comparison_template<texture_flyweight,texture_flyweight>(
+ &textures[0],&textures[0]+LENGTHOF(textures)-1,&textures[1]);
+
+#if !defined(BOOST_NO_EXCEPTIONS)
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,
+ boost::flyweights::key_value<int,throwing_value,from_throwing_value_to_int>
+ >::type throwing_flyweight;
+
+ try{
+ throwing_flyweight fw(0);
+ }catch(const throwing_value_exception&){}
+ try{
+ throwing_flyweight fw=throwing_flyweight(throwing_value());
+ (void)fw;
+ }catch(const throwing_value_exception&){}
+#endif
+
+}
+
+#undef LENGTHOF
+
+#endif
diff --git a/src/boost/libs/flyweight/test/test_custom_factory.cpp b/src/boost/libs/flyweight/test/test_custom_factory.cpp
new file mode 100644
index 000000000..9fec1b408
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_custom_factory.cpp
@@ -0,0 +1,111 @@
+/* Boost.Flyweight test of a custom factory.
+ *
+ * Copyright 2006-2008 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_custom_factory.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/flyweight.hpp>
+#include <boost/flyweight/refcounted.hpp>
+#include <boost/flyweight/simple_locking.hpp>
+#include <boost/flyweight/static_holder.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <list>
+#include "test_basic_template.hpp"
+
+using namespace boost::flyweights;
+
+/* Info on list-update containers:
+ * http://gcc.gnu.org/onlinedocs/libstdc++/ext/pb_ds/lu_based_containers.html
+ */
+
+template<typename Entry,typename Key>
+class lu_factory_class:public factory_marker
+{
+ struct entry_type
+ {
+ entry_type(const Entry& x_):x(x_),count(0){}
+
+ Entry x;
+ std::size_t count;
+ };
+
+ typedef std::list<entry_type> container_type;
+
+public:
+ typedef typename container_type::iterator handle_type;
+
+ handle_type insert(const Entry& x)
+ {
+ handle_type h;
+ for(h=cont.begin();h!=cont.end();++h){
+ if(static_cast<const Key&>(h->x)==static_cast<const Key&>(x)){
+ if(++(h->count)==10){
+ h->count=0;
+ cont.splice(cont.begin(),cont,h); /* move to front */
+ }
+ return h;
+ }
+ }
+ cont.push_back(entry_type(x));
+ h=cont.end();
+ --h;
+ return h;
+ }
+
+ void erase(handle_type h)
+ {
+ cont.erase(h);
+ }
+
+ const Entry& entry(handle_type h){return h->x;}
+
+private:
+ container_type cont;
+
+public:
+ typedef lu_factory_class type;
+ BOOST_MPL_AUX_LAMBDA_SUPPORT(2,lu_factory_class,(Entry,Key))
+};
+
+struct lu_factory:factory_marker
+{
+ template<typename Entry,typename Key>
+ struct apply
+ {
+ typedef lu_factory_class<Entry,Key> type;
+ };
+};
+
+struct custom_factory_flyweight_specifier1
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<T,lu_factory> type;
+ };
+};
+
+struct custom_factory_flyweight_specifier2
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<
+ T,
+ lu_factory_class<boost::mpl::_1,boost::mpl::_2>
+ > type;
+ };
+};
+
+void test_custom_factory()
+{
+ test_basic_template<custom_factory_flyweight_specifier1>();
+ test_basic_template<custom_factory_flyweight_specifier2>();
+}
diff --git a/src/boost/libs/flyweight/test/test_custom_factory.hpp b/src/boost/libs/flyweight/test/test_custom_factory.hpp
new file mode 100644
index 000000000..5b17deb16
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_custom_factory.hpp
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of a custom factory.
+ *
+ * Copyright 2006-2008 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.
+ */
+
+void test_custom_factory();
diff --git a/src/boost/libs/flyweight/test/test_custom_factory_main.cpp b/src/boost/libs/flyweight/test/test_custom_factory_main.cpp
new file mode 100644
index 000000000..95067035d
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_custom_factory_main.cpp
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of a custom factory.
+ *
+ * Copyright 2006-2008 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 <boost/detail/lightweight_test.hpp>
+#include "test_custom_factory.hpp"
+
+int main()
+{
+ test_custom_factory();
+ return boost::report_errors();
+}
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 000000000..5421b8085
--- /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);
+}
diff --git a/src/boost/libs/flyweight/test/test_init.hpp b/src/boost/libs/flyweight/test/test_init.hpp
new file mode 100644
index 000000000..4e869f540
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_init.hpp
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of static data initialization facilities.
+ *
+ * Copyright 2006-2008 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.
+ */
+
+void test_init();
diff --git a/src/boost/libs/flyweight/test/test_init_main.cpp b/src/boost/libs/flyweight/test/test_init_main.cpp
new file mode 100644
index 000000000..213e50513
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_init_main.cpp
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of static data initialization facilities.
+ *
+ * Copyright 2006-2008 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 <boost/detail/lightweight_test.hpp>
+#include "test_init.hpp"
+
+int main()
+{
+ test_init();
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/flyweight/test/test_intermod_holder.cpp b/src/boost/libs/flyweight/test/test_intermod_holder.cpp
new file mode 100644
index 000000000..65ca1c1d9
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_intermod_holder.cpp
@@ -0,0 +1,34 @@
+/* Boost.Flyweight test of intermodule_holder.
+ *
+ * Copyright 2006-2008 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_intermod_holder.hpp"
+
+#include "intermod_holder_dll.hpp"
+#include "test_basic_template.hpp"
+
+using namespace boost::flyweights;
+
+struct intermodule_holder_flyweight_specifier1
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<T,intermodule_holder> type;
+ };
+};
+
+void test_intermodule_holder()
+{
+ test_basic_template<intermodule_holder_flyweight_specifier1>();
+
+ intermodule_flyweight_string str=
+ create_intermodule_flyweight_string("boost");
+ BOOST_TEST(str==intermodule_flyweight_string("boost"));
+}
diff --git a/src/boost/libs/flyweight/test/test_intermod_holder.hpp b/src/boost/libs/flyweight/test/test_intermod_holder.hpp
new file mode 100644
index 000000000..01495b3be
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_intermod_holder.hpp
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of intermodule_holder.
+ *
+ * Copyright 2006-2008 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.
+ */
+
+void test_intermodule_holder();
diff --git a/src/boost/libs/flyweight/test/test_intermod_holder_main.cpp b/src/boost/libs/flyweight/test/test_intermod_holder_main.cpp
new file mode 100644
index 000000000..11519cdc9
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_intermod_holder_main.cpp
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of intermodule_holder.
+ *
+ * Copyright 2006-2008 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 <boost/detail/lightweight_test.hpp>
+#include "test_intermod_holder.hpp"
+
+int main()
+{
+ test_intermodule_holder();
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/flyweight/test/test_multictor.cpp b/src/boost/libs/flyweight/test/test_multictor.cpp
new file mode 100644
index 000000000..2d1532ea7
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_multictor.cpp
@@ -0,0 +1,191 @@
+/* Boost.Flyweight test of flyweight forwarding and initializer_list ctors.
+ *
+ * Copyright 2006-2015 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_multictor.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/detail/workaround.hpp>
+#include <boost/flyweight.hpp>
+#include <boost/functional/hash.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <boost/tuple/tuple_comparison.hpp>
+
+using boost::flyweight;
+
+#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
+#define NONCONST const
+#else
+#define NONCONST
+#endif
+
+struct multictor
+{
+ typedef multictor type;
+
+ multictor():
+ t(0,0,0.0,"",false){}
+ multictor(NONCONST int& x0):
+ t(x0,0,0.0,"",false){}
+ multictor(int x0,NONCONST char& x1):
+ t(x0,x1,0.0,"",false){}
+ multictor(int x0,char x1,NONCONST double& x2):
+ t(x0,x1,x2,"",false){}
+ multictor(int x0,char x1,double x2,NONCONST std::string& x3):
+ t(x0,x1,x2,x3,false){}
+ multictor(int x0,char x1,double x2,const std::string& x3,NONCONST bool& x4):
+ t(x0,x1,x2,x3,x4){}
+
+ friend bool operator==(const type& x,const type& y){return x.t==y.t;}
+ friend bool operator< (const type& x,const type& y){return x.t< y.t;}
+ friend bool operator!=(const type& x,const type& y){return x.t!=y.t;}
+ friend bool operator> (const type& x,const type& y){return x.t> y.t;}
+ friend bool operator>=(const type& x,const type& y){return x.t>=y.t;}
+ friend bool operator<=(const type& x,const type& y){return x.t<=y.t;}
+
+ boost::tuples::tuple<int,char,double,std::string,bool> t;
+};
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+namespace boost{
+#endif
+
+inline std::size_t hash_value(const multictor& x)
+{
+ std::size_t res=0;
+ boost::hash_combine(res,boost::tuples::get<0>(x.t));
+ boost::hash_combine(res,boost::tuples::get<1>(x.t));
+ boost::hash_combine(res,boost::tuples::get<2>(x.t));
+ boost::hash_combine(res,boost::tuples::get<3>(x.t));
+ boost::hash_combine(res,boost::tuples::get<4>(x.t));
+ return res;
+}
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+} /* namespace boost */
+#endif
+
+#if !defined(BOOST_NO_SFINAE)&&!defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+
+#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
+#define INIT0(_) {}
+#define INIT1(a) {a}
+#define INIT2(a,b) {a,b}
+#define INIT_LIST1(a) {a}
+#define INIT_LIST2(a,b) {a,b}
+#else
+#define INIT0(_)
+#define INIT1(a) ((a))
+#define INIT2(a,b) ((a),(b))
+#define INIT_LIST1(a) ({a})
+#define INIT_LIST2(a,b) ({a,b})
+#endif
+
+struct initctor
+{
+ struct arg{arg(int= 0){}};
+
+ initctor():res(-1){}
+ initctor(arg,arg):res(-2){}
+ initctor(int,unsigned int):res(-3){}
+
+ initctor(std::initializer_list<int> list):res(0)
+ {
+ typedef const int* iterator;
+ for(iterator it=list.begin(),it_end=list.end();it!=it_end;++it){
+ res+=*it;
+ }
+ }
+
+ initctor(std::initializer_list<unsigned int> list):res(0)
+ {
+ typedef const unsigned int* iterator;
+ for(iterator it=list.begin(),it_end=list.end();it!=it_end;++it){
+ res+=(int)(*it)*2;
+ }
+ }
+
+ friend bool operator==(const initctor& x,const initctor& y)
+ {
+ return x.res==y.res;
+ }
+
+ int res;
+};
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+namespace boost{
+#endif
+
+inline std::size_t hash_value(const initctor& x)
+{
+ return (std::size_t)(x.res);
+}
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+} /* namespace boost */
+#endif
+
+#endif
+
+void test_multictor()
+{
+ flyweight<multictor> f;
+ multictor m;
+ BOOST_TEST(f==m);
+
+ int x0=1;
+ flyweight<multictor> f0(x0);
+ multictor m0(x0);
+ BOOST_TEST(f0==m0);
+
+ char x1='a';
+ flyweight<multictor> f1(1,x1);
+ multictor m1(1,x1);
+ BOOST_TEST(f1==m1);
+
+ double x2=3.1416;
+ flyweight<multictor> f2(1,'a',x2);
+ multictor m2(1,'a',x2);
+ BOOST_TEST(f2==m2);
+
+ std::string x3("boost");
+ flyweight<multictor> f3(1,'a',3.1416,x3);
+ multictor m3(1,'a',3.1416,x3);
+ BOOST_TEST(f3==m3);
+
+ bool x4=true;
+ flyweight<multictor> f4(1,'a',3.1416,"boost",x4);
+ multictor m4(1,'a',3.1416,"boost",x4);
+ BOOST_TEST(f4==m4);
+
+#if !defined(BOOST_NO_SFINAE)&&!defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+ flyweight<initctor> ff INIT0(~);
+ BOOST_TEST(ff.get().res==-1);
+
+ ff=flyweight<initctor> INIT2(initctor::arg(),1);
+ BOOST_TEST(ff.get().res==-2);
+
+ flyweight<initctor> ff0 INIT2(initctor::arg(),initctor::arg());
+ BOOST_TEST(ff0.get().res==-2);
+
+ ff0={1};
+ BOOST_TEST(ff0.get().res==1);
+
+ flyweight<initctor> ff1 INIT_LIST2(1,2);
+ BOOST_TEST(ff1.get().res==3);
+
+ ff1={1u,2u,3u};
+ BOOST_TEST(ff1.get().res==12);
+
+ flyweight<initctor> ff2 INIT_LIST1(1u);
+ BOOST_TEST(ff2.get().res==2);
+#endif
+}
diff --git a/src/boost/libs/flyweight/test/test_multictor.hpp b/src/boost/libs/flyweight/test/test_multictor.hpp
new file mode 100644
index 000000000..125cc9289
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_multictor.hpp
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of flyweight forwarding ctors.
+ *
+ * Copyright 2006-2008 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.
+ */
+
+void test_multictor();
diff --git a/src/boost/libs/flyweight/test/test_multictor_main.cpp b/src/boost/libs/flyweight/test/test_multictor_main.cpp
new file mode 100644
index 000000000..090aa3e6f
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_multictor_main.cpp
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of flyweight forwarding ctors.
+ *
+ * Copyright 2006-2008 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 <boost/detail/lightweight_test.hpp>
+#include "test_multictor.hpp"
+
+int main()
+{
+ test_multictor();
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/flyweight/test/test_no_locking.cpp b/src/boost/libs/flyweight/test/test_no_locking.cpp
new file mode 100644
index 000000000..a9b493c05
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_no_locking.cpp
@@ -0,0 +1,35 @@
+/* Boost.Flyweight test of no_locking.
+ *
+ * Copyright 2006-2008 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_no_locking.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/flyweight.hpp>
+#include <boost/flyweight/hashed_factory.hpp>
+#include <boost/flyweight/no_locking.hpp>
+#include <boost/flyweight/refcounted.hpp>
+#include <boost/flyweight/static_holder.hpp>
+#include "test_basic_template.hpp"
+
+using namespace boost::flyweights;
+
+struct no_locking_flyweight_specifier
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<T,no_locking> type;
+ };
+};
+
+void test_no_locking()
+{
+ test_basic_template<no_locking_flyweight_specifier>();
+}
diff --git a/src/boost/libs/flyweight/test/test_no_locking.hpp b/src/boost/libs/flyweight/test/test_no_locking.hpp
new file mode 100644
index 000000000..a18470da4
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_no_locking.hpp
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of no_locking.
+ *
+ * Copyright 2006-2008 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.
+ */
+
+void test_no_locking();
diff --git a/src/boost/libs/flyweight/test/test_no_locking_main.cpp b/src/boost/libs/flyweight/test/test_no_locking_main.cpp
new file mode 100644
index 000000000..85d2b090e
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_no_locking_main.cpp
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of no_locking.
+ *
+ * Copyright 2006-2008 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 <boost/detail/lightweight_test.hpp>
+#include "test_no_locking.hpp"
+
+int main()
+{
+ test_no_locking();
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/flyweight/test/test_no_tracking.cpp b/src/boost/libs/flyweight/test/test_no_tracking.cpp
new file mode 100644
index 000000000..876578173
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_no_tracking.cpp
@@ -0,0 +1,35 @@
+/* Boost.Flyweight test of no_tracking.
+ *
+ * Copyright 2006-2008 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_no_tracking.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/flyweight.hpp>
+#include <boost/flyweight/hashed_factory.hpp>
+#include <boost/flyweight/no_tracking.hpp>
+#include <boost/flyweight/simple_locking.hpp>
+#include <boost/flyweight/static_holder.hpp>
+#include "test_basic_template.hpp"
+
+using namespace boost::flyweights;
+
+struct no_tracking_flyweight_specifier
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<T,no_tracking> type;
+ };
+};
+
+void test_no_tracking()
+{
+ test_basic_template<no_tracking_flyweight_specifier>();
+}
diff --git a/src/boost/libs/flyweight/test/test_no_tracking.hpp b/src/boost/libs/flyweight/test/test_no_tracking.hpp
new file mode 100644
index 000000000..99613731a
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_no_tracking.hpp
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of no_tracking.
+ *
+ * Copyright 2006-2008 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.
+ */
+
+void test_no_tracking();
diff --git a/src/boost/libs/flyweight/test/test_no_tracking_main.cpp b/src/boost/libs/flyweight/test/test_no_tracking_main.cpp
new file mode 100644
index 000000000..1cc9decd2
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_no_tracking_main.cpp
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of no_tracking.
+ *
+ * Copyright 2006-2008 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 <boost/detail/lightweight_test.hpp>
+#include "test_no_tracking.hpp"
+
+int main()
+{
+ test_no_tracking();
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/flyweight/test/test_serialization.cpp b/src/boost/libs/flyweight/test/test_serialization.cpp
new file mode 100644
index 000000000..cc348a238
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_serialization.cpp
@@ -0,0 +1,31 @@
+/* Boost.Flyweight test of serialization capabilities.
+ *
+ * Copyright 2006-2014 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_serialization.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight.hpp>
+#include "test_serialization_template.hpp"
+
+using namespace boost::flyweights;
+
+struct serialization_flyweight_specifier
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<T> type;
+ };
+};
+
+void test_serialization()
+{
+ test_serialization_template<serialization_flyweight_specifier>();
+}
diff --git a/src/boost/libs/flyweight/test/test_serialization.hpp b/src/boost/libs/flyweight/test/test_serialization.hpp
new file mode 100644
index 000000000..066f29ac8
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_serialization.hpp
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of serialization capabilities.
+ *
+ * Copyright 2006-2014 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.
+ */
+
+void test_serialization();
diff --git a/src/boost/libs/flyweight/test/test_serialization_main.cpp b/src/boost/libs/flyweight/test/test_serialization_main.cpp
new file mode 100644
index 000000000..d614e6b1d
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_serialization_main.cpp
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of serialization capabilities.
+ *
+ * Copyright 2006-2014 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 <boost/detail/lightweight_test.hpp>
+#include "test_serialization.hpp"
+
+int main()
+{
+ test_serialization();
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/flyweight/test/test_serialization_template.hpp b/src/boost/libs/flyweight/test/test_serialization_template.hpp
new file mode 100644
index 000000000..767708187
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_serialization_template.hpp
@@ -0,0 +1,128 @@
+/* Boost.Flyweight test template for serialization capabilities.
+ *
+ * Copyright 2006-2014 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.
+ */
+
+#ifndef BOOST_FLYWEIGHT_TEST_SERIALIZATION_TEMPLATE_HPP
+#define BOOST_FLYWEIGHT_TEST_SERIALIZATION_TEMPLATE_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/archive/text_oarchive.hpp>
+#include <boost/archive/text_iarchive.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/flyweight/key_value.hpp>
+#include <boost/flyweight/serialize.hpp>
+#include <boost/functional/hash.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/serialization/vector.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include "heavy_objects.hpp"
+
+#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
+
+struct tracked_string
+{
+ typedef tracked_string type;
+
+ tracked_string(){}
+ tracked_string(const char* str_):str(str_){}
+
+ const std::string& get()const{return str;}
+
+ friend bool operator==(const type& x,const type& y){return x.str==y.str;}
+ friend bool operator< (const type& x,const type& y){return x.str< y.str;}
+ friend bool operator!=(const type& x,const type& y){return x.str!=y.str;}
+ friend bool operator> (const type& x,const type& y){return x.str> y.str;}
+ friend bool operator>=(const type& x,const type& y){return x.str>=y.str;}
+ friend bool operator<=(const type& x,const type& y){return x.str<=y.str;}
+
+private:
+ friend class boost::serialization::access;
+
+ template<class Archive>
+ void serialize(Archive& ar,const unsigned int){ar&str;}
+
+ std::string str;
+};
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+namespace boost{
+#endif
+
+inline std::size_t hash_value(const tracked_string& x)
+{
+ boost::hash<std::string> h;
+ return h(x.get());
+}
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+} /* namespace boost */
+#endif
+
+template<typename Flyweight,typename ForwardIterator>
+void test_serialization_template(
+ ForwardIterator first,ForwardIterator last
+ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight))
+{
+ std::vector<Flyweight> v1;
+ while(first!=last)v1.push_back(Flyweight(*first++));
+ std::ostringstream oss;
+ {
+ const std::vector<Flyweight>& crv1=v1;
+ boost::archive::text_oarchive oa(oss);
+ oa<<crv1;
+ }
+
+ std::vector<Flyweight> v2;
+ {
+ std::istringstream iss(oss.str());
+ boost::archive::text_iarchive ia(iss);
+ ia>>v2;
+ }
+
+ BOOST_TEST(v1==v2);
+}
+
+template<typename FlyweightSpecifier>
+void test_serialization_template(
+ BOOST_EXPLICIT_TEMPLATE_TYPE(FlyweightSpecifier))
+{
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,std::string
+ >::type string_flyweight;
+
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,tracked_string
+ >::type tracked_string_flyweight;
+
+ typedef typename boost::mpl::apply1<
+ FlyweightSpecifier,
+ boost::flyweights::key_value<std::string,texture,from_texture_to_string>
+ >::type texture_flyweight;
+
+ const char* words[]={"hello","boost","flyweight","boost","bye","c++","c++"};
+ test_serialization_template<string_flyweight>(
+ &words[0],&words[0]+LENGTHOF(words));
+ test_serialization_template<tracked_string_flyweight>(
+ &words[0],&words[0]+LENGTHOF(words));
+
+ const char* textures[]={
+ "wood","grass","sand","granite","terracotta","wood","sand","grass"};
+ test_serialization_template<texture_flyweight>(
+ &textures[0],&textures[0]+LENGTHOF(textures));
+}
+
+#undef LENGTHOF
+
+#endif
diff --git a/src/boost/libs/flyweight/test/test_set_factory.cpp b/src/boost/libs/flyweight/test/test_set_factory.cpp
new file mode 100644
index 000000000..06bf1493d
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_set_factory.cpp
@@ -0,0 +1,72 @@
+/* Boost.Flyweight test of set_factory.
+ *
+ * Copyright 2006-2013 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_set_factory.hpp"
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/flyweight/flyweight.hpp>
+#include <boost/flyweight/refcounted.hpp>
+#include <boost/flyweight/set_factory.hpp>
+#include <boost/flyweight/simple_locking.hpp>
+#include <boost/flyweight/static_holder.hpp>
+#include <functional>
+#include "test_basic_template.hpp"
+
+using namespace boost::flyweights;
+
+struct set_factory_flyweight_specifier1
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<T,set_factory<> > type;
+ };
+};
+
+struct set_factory_flyweight_specifier2
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<
+ T,
+ static_holder_class<boost::mpl::_1>,
+ set_factory_class<
+ boost::mpl::_1,boost::mpl::_2,
+ std::greater<boost::mpl::_2>,
+ std::allocator<boost::mpl::_1>
+ >
+ > type;
+ };
+};
+
+struct set_factory_flyweight_specifier3
+{
+ template<typename T>
+ struct apply
+ {
+ typedef flyweight<
+ T,
+ set_factory<
+ std::greater<boost::mpl::_2>,
+ std::allocator<boost::mpl::_1>
+ >,
+ static_holder_class<boost::mpl::_1>,
+ tag<char>
+ > type;
+ };
+};
+
+void test_set_factory()
+{
+ test_basic_template<set_factory_flyweight_specifier1>();
+ test_basic_template<set_factory_flyweight_specifier2>();
+ test_basic_template<set_factory_flyweight_specifier3>();
+}
diff --git a/src/boost/libs/flyweight/test/test_set_factory.hpp b/src/boost/libs/flyweight/test/test_set_factory.hpp
new file mode 100644
index 000000000..6e783e3a2
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_set_factory.hpp
@@ -0,0 +1,11 @@
+/* Boost.Flyweight test of set_factory.
+ *
+ * Copyright 2006-2008 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.
+ */
+
+void test_set_factory();
diff --git a/src/boost/libs/flyweight/test/test_set_factory_main.cpp b/src/boost/libs/flyweight/test/test_set_factory_main.cpp
new file mode 100644
index 000000000..c0e588515
--- /dev/null
+++ b/src/boost/libs/flyweight/test/test_set_factory_main.cpp
@@ -0,0 +1,18 @@
+/* Boost.Flyweight test of set_factory.
+ *
+ * Copyright 2006-2008 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 <boost/detail/lightweight_test.hpp>
+#include "test_set_factory.hpp"
+
+int main()
+{
+ test_set_factory();
+ return boost::report_errors();
+}