Squashed 'third_party/boostorg/any/' content from commit d962e21
Change-Id: I308196902114eb74127ee7bfff922a0b8a885a4d
git-subtree-dir: third_party/boostorg/any
git-subtree-split: d962e210f8fc0cfb99f475627563193ba09cbf16
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..3e84d7c
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,96 @@
+* text=auto !eol svneol=native#text/plain
+*.gitattributes text svneol=native#text/plain
+
+# Scriptish formats
+*.bat text svneol=native#text/plain
+*.bsh text svneol=native#text/x-beanshell
+*.cgi text svneol=native#text/plain
+*.cmd text svneol=native#text/plain
+*.js text svneol=native#text/javascript
+*.php text svneol=native#text/x-php
+*.pl text svneol=native#text/x-perl
+*.pm text svneol=native#text/x-perl
+*.py text svneol=native#text/x-python
+*.sh eol=lf svneol=LF#text/x-sh
+configure eol=lf svneol=LF#text/x-sh
+
+# Image formats
+*.bmp binary svneol=unset#image/bmp
+*.gif binary svneol=unset#image/gif
+*.ico binary svneol=unset#image/ico
+*.jpeg binary svneol=unset#image/jpeg
+*.jpg binary svneol=unset#image/jpeg
+*.png binary svneol=unset#image/png
+*.tif binary svneol=unset#image/tiff
+*.tiff binary svneol=unset#image/tiff
+*.svg text svneol=native#image/svg%2Bxml
+
+# Data formats
+*.pdf binary svneol=unset#application/pdf
+*.avi binary svneol=unset#video/avi
+*.doc binary svneol=unset#application/msword
+*.dsp text svneol=crlf#text/plain
+*.dsw text svneol=crlf#text/plain
+*.eps binary svneol=unset#application/postscript
+*.gz binary svneol=unset#application/gzip
+*.mov binary svneol=unset#video/quicktime
+*.mp3 binary svneol=unset#audio/mpeg
+*.ppt binary svneol=unset#application/vnd.ms-powerpoint
+*.ps binary svneol=unset#application/postscript
+*.psd binary svneol=unset#application/photoshop
+*.rdf binary svneol=unset#text/rdf
+*.rss text svneol=unset#text/xml
+*.rtf binary svneol=unset#text/rtf
+*.sln text svneol=native#text/plain
+*.swf binary svneol=unset#application/x-shockwave-flash
+*.tgz binary svneol=unset#application/gzip
+*.vcproj text svneol=native#text/xml
+*.vcxproj text svneol=native#text/xml
+*.vsprops text svneol=native#text/xml
+*.wav binary svneol=unset#audio/wav
+*.xls binary svneol=unset#application/vnd.ms-excel
+*.zip binary svneol=unset#application/zip
+
+# Text formats
+.htaccess text svneol=native#text/plain
+*.bbk text svneol=native#text/xml
+*.cmake text svneol=native#text/plain
+*.css text svneol=native#text/css
+*.dtd text svneol=native#text/xml
+*.htm text svneol=native#text/html
+*.html text svneol=native#text/html
+*.ini text svneol=native#text/plain
+*.log text svneol=native#text/plain
+*.mak text svneol=native#text/plain
+*.qbk text svneol=native#text/plain
+*.rst text svneol=native#text/plain
+*.sql text svneol=native#text/x-sql
+*.txt text svneol=native#text/plain
+*.xhtml text svneol=native#text/xhtml%2Bxml
+*.xml text svneol=native#text/xml
+*.xsd text svneol=native#text/xml
+*.xsl text svneol=native#text/xml
+*.xslt text svneol=native#text/xml
+*.xul text svneol=native#text/xul
+*.yml text svneol=native#text/plain
+boost-no-inspect text svneol=native#text/plain
+CHANGES text svneol=native#text/plain
+COPYING text svneol=native#text/plain
+INSTALL text svneol=native#text/plain
+Jamfile text svneol=native#text/plain
+Jamroot text svneol=native#text/plain
+Jamfile.v2 text svneol=native#text/plain
+Jamrules text svneol=native#text/plain
+Makefile* text svneol=native#text/plain
+README text svneol=native#text/plain
+TODO text svneol=native#text/plain
+
+# Code formats
+*.c text svneol=native#text/plain
+*.cpp text svneol=native#text/plain
+*.h text svneol=native#text/plain
+*.hpp text svneol=native#text/plain
+*.ipp text svneol=native#text/plain
+*.tpp text svneol=native#text/plain
+*.jam text svneol=native#text/plain
+*.java text svneol=native#text/plain
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..1c60324
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,119 @@
+# Use, modification, and distribution are
+# subject to 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)
+#
+# Copyright Antony Polukhin 2014-2016.
+
+#
+# See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file
+# and how it can be used with Boost libraries.
+#
+# File revision #7
+
+sudo: false
+language: cpp
+compiler:
+ - gcc
+# - clang
+
+os:
+ - linux
+
+env:
+ global:
+ # Autodetect Boost branch by using the following code: - BRANCH_TO_TEST=$TRAVIS_BRANCH
+ # or just directly specify it
+ - BRANCH_TO_TEST=$TRAVIS_BRANCH
+
+ # Files, which coverage results must be ignored (files from other projects).
+ # Example: - IGNORE_COVERAGE='*/boost/progress.hpp */filesystem/src/*'
+ - IGNORE_COVERAGE=''
+
+ # Explicitly remove the following library from Boost. This may be usefull, if you're for example running Travis
+ # from `Boost.DLL` repo, while Boost already has `dll`.
+ #
+ # By default is eaual to - BOOST_REMOVE=$(basename $TRAVIS_BUILD_DIR)
+ # This will force to use local repo content, instead of the Boost's default.
+ - BOOST_REMOVE=$(basename $TRAVIS_BUILD_DIR)
+
+ matrix:
+ # Note that "--coverage -fsanitize=address,leak,undefined -DBOOST_TRAVISCI_BUILD" are added automatically lower in code
+ - CXX_FLAGS="-std=c++98" LINK_FLAGS="" TOOLSET=gcc-6
+ - CXX_FLAGS="-std=c++11" LINK_FLAGS="" TOOLSET=gcc-6
+ - CXX_FLAGS="-std=c++1y" LINK_FLAGS="" TOOLSET=gcc-6
+ #- CXX_FLAGS="-std=c++11 -stdlib=libc++" LINK_FLAGS="-stdlib=libc++" TOOLSET=clang
+ #- CXX_FLAGS="-std=c++1y -stdlib=libc++" LINK_FLAGS="-stdlib=libc++" TOOLSET=clang
+
+###############################################################################################################
+# From this point and below code is same for all the Boost libs
+###############################################################################################################
+
+
+# Installing additional tools
+addons:
+ apt:
+ sources:
+ - ubuntu-toolchain-r-test
+ - git-core
+ packages:
+ - git
+ - python-yaml
+ - gcc-6
+ - g++-6
+ - clang
+ - libc++-dev
+
+before_install:
+ # Set this to the name of the library
+ - PROJECT_TO_TEST=`basename $TRAVIS_BUILD_DIR`
+ # Cloning Boost libraries (fast nondeep cloning)
+ - BOOST=$HOME/boost-local
+ - echo "Testing $PROJECT_TO_TEST, to remove $BOOST/libs/$BOOST_REMOVE, testing branch $BRANCH_TO_TEST"
+ - git init $BOOST
+ - cd $BOOST
+ - git remote add --no-tags -t $BRANCH_TO_TEST origin https://github.com/boostorg/boost.git
+ - git fetch --depth=1
+ - git checkout $BRANCH_TO_TEST
+ - git submodule update --jobs=3 --init --merge
+ - git remote set-branches --add origin $BRANCH_TO_TEST
+ - git pull --recurse-submodules
+ - git status
+ - rm -rf $BOOST/libs/$BOOST_REMOVE
+ - mv $TRAVIS_BUILD_DIR $BOOST/libs/$PROJECT_TO_TEST
+ - TRAVIS_BUILD_DIR=$BOOST/libs/$PROJECT_TO_TEST
+ - ./bootstrap.sh
+ - ./b2 headers
+ - cd $BOOST/libs/$PROJECT_TO_TEST/test/
+
+script:
+ # `--coverage` flags required to generate coverage info for Coveralls
+ - ../../../b2 "testing.launcher=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.3 " address-model=64 architecture=x86 toolset=$TOOLSET cxxflags="--coverage -fsanitize=address,leak,undefined -DBOOST_TRAVISCI_BUILD $CXX_FLAGS" linkflags="$LINK_FLAGS --coverage -lasan -lubsan"
+
+after_success:
+ # Copying Coveralls data to a separate folder
+ - mkdir -p $TRAVIS_BUILD_DIR/coverals
+ - find ../../../bin.v2/ -name "*.gcda" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
+ - find ../../../bin.v2/ -name "*.gcno" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
+ - find ../../../bin.v2/ -name "*.da" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
+ - find ../../../bin.v2/ -name "*.no" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
+ - wget https://github.com/linux-test-project/lcov/archive/v1.12.zip
+ - unzip v1.12.zip
+ - LCOV="`pwd`/lcov-1.12/bin/lcov --gcov-tool gcov-6"
+
+ # Preparing Coveralls data by changind data format to a readable one
+ - echo "$LCOV --directory $TRAVIS_BUILD_DIR/coverals --base-directory `pwd` --capture --output-file $TRAVIS_BUILD_DIR/coverals/coverage.info"
+ - $LCOV --directory $TRAVIS_BUILD_DIR/coverals --base-directory `pwd` --capture --output-file $TRAVIS_BUILD_DIR/coverals/coverage.info
+
+ # ... erasing /test/ /example/ folder data
+ - cd $BOOST
+ - $LCOV --remove $TRAVIS_BUILD_DIR/coverals/coverage.info "/usr*" "*/$PROJECT_TO_TEST/test/*" $IGNORE_COVERAGE "*/$PROJECT_TO_TEST/tests/*" "*/$PROJECT_TO_TEST/examples/*" "*/$PROJECT_TO_TEST/example/*" -o $TRAVIS_BUILD_DIR/coverals/coverage.info
+
+ # ... erasing data that is not related to this project directly
+ - OTHER_LIBS=`grep "submodule .*" .gitmodules | sed 's/\[submodule\ "\(.*\)"\]/"\*\/boost\/\1\.hpp" "\*\/boost\/\1\/\*"/g'| sed "/\"\*\/boost\/$PROJECT_TO_TEST\/\*\"/d" | sed ':a;N;$!ba;s/\n/ /g'`
+ - echo $OTHER_LIBS
+ - eval "$LCOV --remove $TRAVIS_BUILD_DIR/coverals/coverage.info $OTHER_LIBS -o $TRAVIS_BUILD_DIR/coverals/coverage.info"
+
+ # Sending data to Coveralls
+ - cd $TRAVIS_BUILD_DIR
+ - gem install coveralls-lcov
+ - coveralls-lcov coverals/coverage.info
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..2da4bdc
--- /dev/null
+++ b/README.md
@@ -0,0 +1,16 @@
+# [Boost.Any](http://boost.org/libs/any)
+Boost.Any is a part of the [Boost C++ Libraries](http://github.com/boostorg). It is a safe, generic container for single values of different value types.
+
+### Test results
+
+@ | Build | Tests coverage | More info
+----------------|-------------- | -------------- |-----------
+Develop branch: | [](https://travis-ci.org/apolukhin/any) [](https://ci.appveyor.com/project/apolukhin/any/branch/develop) | [](https://coveralls.io/r/apolukhin/any?branch=develop) | [details...](http://www.boost.org/development/tests/develop/developer/any.html)
+Master branch: | [](https://travis-ci.org/apolukhin/any) [](https://ci.appveyor.com/project/apolukhin/any/branch/master) | [](https://coveralls.io/r/apolukhin/any?branch=master) | [details...](http://www.boost.org/development/tests/master/developer/any.html)
+
+
+[Open Issues](https://svn.boost.org/trac/boost/query?status=!closed&component=any)
+
+### License
+
+Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).
diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2
new file mode 100644
index 0000000..8e2dca9
--- /dev/null
+++ b/doc/Jamfile.v2
@@ -0,0 +1,19 @@
+# Copyright Antony Polukhin 2013. Use, modification, and distribution are
+# subject to 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)
+
+using boostbook ;
+
+boostbook standalone
+ : any.xml
+ : <xsl:param>boost.root=../../../.. ;
+
+###############################################################################
+alias boostdoc
+ : any.xml
+ :
+ :
+ : ;
+explicit boostdoc ;
+alias boostrelease ;
+explicit boostrelease ;
diff --git a/doc/any.xml b/doc/any.xml
new file mode 100644
index 0000000..92944cc
--- /dev/null
+++ b/doc/any.xml
@@ -0,0 +1,579 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+ "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<library name="Any" dirname="any" xmlns:xi="http://www.w3.org/2001/XInclude"
+ id="any" last-revision="$Date$">
+ <libraryinfo>
+ <author>
+ <firstname>Kevlin</firstname>
+ <surname>Henney</surname>
+ </author>
+
+ <copyright>
+ <year>2001</year>
+ <holder>Kevlin Henney</holder>
+ </copyright>
+
+ <librarypurpose>
+ Safe, generic container for single values of different value types
+ </librarypurpose>
+ <librarycategory name="category:data-structures"/>
+
+ <legalnotice>
+ <para>Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file <filename>LICENSE_1_0.txt</filename> or copy at
+ <ulink
+ url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>)
+ </para>
+ </legalnotice>
+ </libraryinfo>
+
+ <title>Boost.Any</title>
+
+ <section>
+ <title>Introduction</title>
+
+ <para>There are times when a generic (in the sense of
+ <emphasis>general</emphasis> as opposed to
+ <emphasis>template-based programming</emphasis>) type is needed:
+ variables that are truly variable, accommodating values of many
+ other more specific types rather than C++'s normal strict and
+ static types. We can distinguish three basic kinds of generic
+ type:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>Converting types that can hold one of a number of
+ possible value types, e.g. <code>int</code> and
+ <code>string</code>, and freely convert between them, for
+ instance interpreting <code>5</code> as <code>"5"</code> or
+ vice-versa. Such types are common in scripting and other
+ interpreted
+ languages.
+ <code><functionname>boost::lexical_cast</functionname></code>
+ supports such conversion functionality.</para>
+ </listitem>
+ <listitem>
+ <para>
+ Discriminated types that contain values of different types but
+ do not attempt conversion between them, i.e. <code>5</code> is
+ held strictly as an <code>int</code> and is not implicitly
+ convertible either to <code>"5"</code> or to
+ <code>5.0</code>. Their indifference to interpretation but
+ awareness of type effectively makes them safe, generic
+ containers of single values, with no scope for surprises from
+ ambiguous conversions.</para>
+ </listitem>
+ <listitem>
+ <para>
+ Indiscriminate types that can refer to anything but are
+ oblivious to the actual underlying type, entrusting all forms
+ of access and interpretation to the programmer. This niche is
+ dominated by <code>void *</code>, which offers plenty of scope
+ for surprising, undefined behavior.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>The <code><classname>boost::any</classname></code> class
+ (based on the class of the same name described in <ulink
+ url="http://www.two-sdg.demon.co.uk/curbralan/papers/ValuedConversions.pdf">"Valued
+ Conversions"</ulink> by Kevlin Henney, <emphasis>C++
+ Report</emphasis> 12(7), July/August 2000) is a variant value type
+ based on the second category. It supports copying of any value
+ type and safe checked extraction of that value strictly against
+ its type. A similar design, offering more appropriate operators,
+ can be used for a generalized function adaptor,
+ <code>any_function</code>, a generalized iterator adaptor,
+ <code>any_iterator</code>, and other object types that need
+ uniform runtime treatment but support only compile-time template
+ parameter conformance.</para>
+ </section>
+
+ <section>
+ <title>Examples</title>
+
+ <using-namespace name="boost"/>
+ <using-class name="boost::any"/>
+
+ <para>The following code demonstrates the syntax for using
+ implicit conversions to and copying of any objects:</para>
+
+<programlisting name="any.example.first">
+#include <list>
+#include <boost/any.hpp>
+
+using <functionname>boost::any_cast</functionname>;
+typedef std::list<<classname>boost::any</classname>> many;
+
+void append_int(many & values, int value)
+{
+ <classname>boost::any</classname> to_append = value;
+ values.push_back(to_append);
+}
+
+void append_string(many & values, const std::string & value)
+{
+ values.push_back(value);
+}
+
+void append_char_ptr(many & values, const char * value)
+{
+ values.push_back(value);
+}
+
+void append_any(many & values, const <classname>boost::any</classname> & value)
+{
+ values.push_back(value);
+}
+
+void append_nothing(many & values)
+{
+ values.push_back(<classname>boost::any</classname>());
+}
+</programlisting>
+
+ <para>The following predicates follow on from the previous
+ definitions and demonstrate the use of queries on any
+ objects:</para>
+
+<programlisting name="any.example.second">
+bool is_empty(const <classname>boost::any</classname> & operand)
+{
+ return operand.<methodname>empty</methodname>();
+}
+
+bool is_int(const <classname>boost::any</classname> & operand)
+{
+ return operand.<methodname>type</methodname>() == typeid(int);
+}
+
+bool is_char_ptr(const <classname>boost::any</classname> & operand)
+{
+ try
+ {
+ <functionname>any_cast</functionname><const char *>(operand);
+ return true;
+ }
+ catch(const <classname>boost::bad_any_cast</classname> &)
+ {
+ return false;
+ }
+}
+
+bool is_string(const <classname>boost::any</classname> & operand)
+{
+ return <functionname>any_cast</functionname><std::string>(&operand);
+}
+
+void count_all(many & values, std::ostream & out)
+{
+ out << "#empty == "
+ << std::count_if(values.begin(), values.end(), is_empty) << std::endl;
+ out << "#int == "
+ << std::count_if(values.begin(), values.end(), is_int) << std::endl;
+ out << "#const char * == "
+ << std::count_if(values.begin(), values.end(), is_char_ptr) << std::endl;
+ out << "#string == "
+ << std::count_if(values.begin(), values.end(), is_string) << std::endl;
+}
+</programlisting>
+
+ <para>The following type, patterned after the OMG's Property Service, defines name-value pairs for arbitrary value types:</para>
+
+<programlisting>
+struct property
+{
+ property();
+ property(const std::string &, const <classname>boost::any</classname> &);
+
+ std::string name;
+ <classname>boost::any</classname> value;
+};
+
+typedef std::list<property> properties;
+</programlisting>
+
+ <para>The following base class demonstrates one approach to
+ runtime polymorphism based callbacks that also require arbitrary
+ argument types. The absence of virtual member templates requires
+ that different solutions have different trade-offs in terms of
+ efficiency, safety, and generality. Using a checked variant type
+ offers one approach:</para>
+
+<programlisting>
+class consumer
+{
+public:
+ virtual void notify(const <classname>any</classname> &) = 0;
+ ...
+};
+</programlisting>
+ </section>
+
+ <library-reference>
+ <section id="any.ValueType">
+ <title><emphasis>ValueType</emphasis> requirements</title>
+
+ <para>Values are strongly informational objects for which
+ identity is not significant, i.e. the focus is principally on
+ their state content and any behavior organized around
+ that. Another distinguishing feature of values is their
+ granularity: normally fine-grained objects representing simple
+ concepts in the system such as quantities.</para>
+
+ <para>As the emphasis of a value lies in its state not its
+ identity, values can be copied and typically assigned one to
+ another, requiring the explicit or implicit definition of a
+ public copy constructor and public assignment operator. Values
+ typically live within other scopes, i.e. within objects or
+ blocks, rather than on the heap. Values are therefore normally
+ passed around and manipulated directly as variables or through
+ references, but not as pointers that emphasize identity and
+ indirection.</para>
+
+ <para>The specific requirements on value types to be used in an
+ <code><classname alt="boost::any">any</classname></code>
+ are:</para>
+
+ <itemizedlist spacing="compact">
+ <listitem><simpara>A <emphasis>ValueType</emphasis> is
+ <emphasis>CopyConstructible</emphasis> [20.1.3].</simpara>
+ </listitem>
+
+ <listitem><simpara>The destructor for a
+ <emphasis>ValueType</emphasis> upholds the no-throw
+ exception-safety guarantee.</simpara>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <header name="boost/any.hpp">
+ <namespace name="boost">
+ <class name="bad_any_cast">
+ <inherit access="public">
+ <classname>std::bad_cast</classname>
+ </inherit>
+ <purpose>The exception thrown in the event of a failed
+ <code><functionname>any_cast</functionname></code> of an
+ <code><classname>any</classname></code> value.</purpose>
+
+ <method name="what" specifiers="virtual" cv="const">
+ <type>const char *</type>
+ </method>
+ </class>
+
+ <class name="any">
+ <purpose>A class whose instances can hold instances of any
+ type that satisfies <link
+ linkend="any.ValueType">ValueType</link>
+ requirements.</purpose>
+
+ <constructor>
+ <postconditions><simpara><code>this-><methodname>empty</methodname>()</code></simpara></postconditions>
+ </constructor>
+
+ <constructor>
+ <parameter name="other">
+ <paramtype>const <classname>any</classname> &</paramtype>
+ </parameter>
+
+ <effects><simpara> Copy constructor that copies content of
+ <code>other</code> into new instance, so that any content
+ is equivalent in both type and value to the content of
+ <code>other</code>, or empty if <code>other</code> is
+ empty. </simpara></effects>
+
+ <throws><simpara>May fail with a
+ <code><classname>std::bad_alloc</classname></code>
+ exception or any exceptions arising from the copy
+ constructor of the contained type.</simpara></throws>
+ </constructor>
+
+ <constructor>
+ <parameter name="other">
+ <paramtype><classname>any</classname> &&</paramtype>
+ </parameter>
+
+ <effects><simpara> Move constructor that moves content of
+ <code>other</code> into new instance and leaves <code>other</code>
+ empty. </simpara></effects>
+ <precondition>C++11 compatible compiler.</precondition>
+ <postconditions><simpara><code>other-><methodname>empty</methodname>()</code></simpara></postconditions>
+ <throws><simpara>Nothing.</simpara></throws>
+ </constructor>
+
+ <constructor>
+ <template>
+ <template-type-parameter name="ValueType"/>
+ </template>
+
+ <parameter name="value">
+ <paramtype>const ValueType &</paramtype>
+ </parameter>
+
+ <effects><simpara>Makes a copy of <code>value</code>, so
+ that the initial content of the new instance is equivalent
+ in both type and value to
+ <code>value</code>.</simpara></effects>
+
+ <throws><simpara><code><classname>std::bad_alloc</classname></code>
+ or any exceptions arising from the copy constructor of the
+ contained type.</simpara></throws>
+ </constructor>
+
+ <constructor>
+ <template>
+ <template-type-parameter name="ValueType"/>
+ </template>
+
+ <parameter name="value">
+ <paramtype>ValueType &&</paramtype>
+ </parameter>
+
+ <effects><simpara>Forwards <code>value</code>, so
+ that the initial content of the new instance is equivalent
+ in both type and value to
+ <code>value</code> before the forward.</simpara></effects>
+
+ <precondition>C++11 compatible compiler.</precondition>
+ <throws><simpara><code><classname>std::bad_alloc</classname></code>
+ or any exceptions arising from the copy constructor of the
+ contained type.</simpara></throws>
+ </constructor>
+
+ <destructor>
+ <effects><simpara>Releases any and all resources used in
+ management of instance.</simpara></effects>
+ <throws><simpara>Nothing.</simpara></throws>
+ </destructor>
+
+ <copy-assignment>
+ <type><classname>any</classname> &</type>
+
+ <parameter name="rhs">
+ <paramtype>const <classname>any</classname> &</paramtype>
+ </parameter>
+
+ <effects><simpara>Copies content of <code>rhs</code> into
+ current instance, discarding previous content, so that the
+ new content is equivalent in both type and value to the
+ content of <code>rhs</code>, or empty if
+ <code>rhs.<methodname>empty</methodname>()</code>.</simpara></effects>
+
+ <throws><simpara><code><classname>std::bad_alloc</classname></code>
+ or any exceptions arising from the copy constructor of the
+ contained type. Assignment satisfies the strong guarantee
+ of exception safety.</simpara></throws>
+ </copy-assignment>
+
+ <copy-assignment>
+ <type><classname>any</classname> &</type>
+
+ <parameter name="rhs">
+ <paramtype><classname>any</classname> &&</paramtype>
+ </parameter>
+
+ <effects><simpara>Moves content of <code>rhs</code> into
+ current instance, discarding previous content, so that the
+ new content is equivalent in both type and value to the
+ content of <code>rhs</code> before move, or empty if
+ <code>rhs.<methodname>empty</methodname>()</code>.</simpara></effects>
+
+ <precondition>C++11 compatible compiler.</precondition>
+ <postconditions><simpara><code>rhs-><methodname>empty</methodname>()</code></simpara></postconditions>
+ <throws><simpara>Nothing.</simpara></throws>
+ </copy-assignment>
+
+ <copy-assignment>
+ <template>
+ <template-type-parameter name="ValueType"/>
+ </template>
+
+ <type><classname>any</classname> &</type>
+
+ <parameter name="rhs">
+ <paramtype>const ValueType &</paramtype>
+ </parameter>
+
+ <effects><simpara>Makes a copy of <code>rhs</code>,
+ discarding previous content, so that the new content of is
+ equivalent in both type and value to
+ <code>rhs</code>.</simpara></effects>
+
+ <throws><simpara><code><classname>std::bad_alloc</classname></code>
+ or any exceptions arising from the copy constructor of the
+ contained type. Assignment satisfies the strong guarantee
+ of exception safety.</simpara></throws>
+ </copy-assignment>
+
+ <copy-assignment>
+ <template>
+ <template-type-parameter name="ValueType"/>
+ </template>
+
+ <type><classname>any</classname> &</type>
+
+ <parameter name="rhs">
+ <paramtype>ValueType &&</paramtype>
+ </parameter>
+
+ <effects><simpara>Forwards <code>rhs</code>,
+ discarding previous content, so that the new content of is
+ equivalent in both type and value to
+ <code>rhs</code> before forward.</simpara></effects>
+
+ <precondition>C++11 compatible compiler.</precondition>
+ <throws><simpara><code><classname>std::bad_alloc</classname></code>
+ or any exceptions arising from the move or copy constructor of the
+ contained type. Assignment satisfies the strong guarantee
+ of exception safety.</simpara></throws>
+ </copy-assignment>
+
+ <method-group name="modifiers">
+ <method name="swap">
+ <type><classname>any</classname> &</type>
+
+ <parameter name="rhs">
+ <paramtype><classname>any</classname> &</paramtype>
+ </parameter>
+
+ <effects><simpara>Exchange of the contents of
+ <code>*this</code> and
+ <code>rhs</code>.</simpara></effects>
+
+ <returns><simpara><code>*this</code></simpara></returns>
+
+ <throws><simpara>Nothing.</simpara></throws>
+ </method>
+ </method-group>
+
+ <method-group name="queries">
+ <method name="empty" cv="const">
+ <type>bool</type>
+
+ <returns><simpara><code>true</code> if instance is
+ empty, otherwise <code>false</code>.</simpara></returns>
+
+ <throws><simpara>Nothing.</simpara></throws>
+ </method>
+
+ <method name="type" cv="const">
+ <type>const <classname>std::type_info</classname> &</type>
+
+ <returns><simpara>the <code>typeid</code> of the
+ contained value if instance is non-empty, otherwise
+ <code>typeid(void)</code>.</simpara></returns>
+
+ <notes><simpara>Useful for querying against types known
+ either at compile time or only at
+ runtime.</simpara></notes>
+ </method>
+ </method-group>
+ </class>
+
+ <function name="swap">
+ <type>void</type>
+ <parameter name="lhs">
+ <paramtype><classname>any</classname> &</paramtype>
+ </parameter>
+ <parameter name="rhs">
+ <paramtype><classname>any</classname> &</paramtype>
+ </parameter>
+
+ <effects><simpara>Exchange of the contents of
+ <code>lhs</code> and
+ <code>rhs</code>.</simpara></effects>
+
+ <throws><simpara>Nothing.</simpara></throws>
+ </function>
+
+ <overloaded-function name="any_cast">
+ <signature>
+ <template>
+ <template-type-parameter name="T"/>
+ </template>
+
+ <type>T</type>
+
+ <parameter name="operand">
+ <paramtype><classname>any</classname> &</paramtype>
+ </parameter>
+ </signature>
+
+ <signature>
+ <template>
+ <template-type-parameter name="T"/>
+ </template>
+
+ <type>T</type>
+
+ <parameter name="operand">
+ <paramtype><classname>any</classname> &&</paramtype>
+ </parameter>
+ </signature>
+
+ <signature>
+ <template>
+ <template-type-parameter name="T"/>
+ </template>
+
+ <type>T</type>
+
+ <parameter name="operand">
+ <paramtype>const <classname>any</classname> &</paramtype>
+ </parameter>
+ </signature>
+
+ <signature>
+ <template>
+ <template-type-parameter name="ValueType"/>
+ </template>
+
+ <type>const ValueType *</type>
+
+ <parameter name="operand">
+ <paramtype>const <classname>any</classname> *</paramtype>
+ </parameter>
+ </signature>
+
+ <signature>
+ <template>
+ <template-type-parameter name="ValueType"/>
+ </template>
+
+ <type>ValueType *</type>
+
+ <parameter name="operand">
+ <paramtype><classname>any</classname> *</paramtype>
+ </parameter>
+ </signature>
+
+ <purpose><simpara>Custom keyword cast for extracting a value
+ of a given type from an
+ <code><classname>any</classname></code>.</simpara></purpose>
+
+ <returns><simpara> If passed a pointer, it returns a
+ similarly qualified pointer to the value content if
+ successful, otherwise null is returned.
+ If T is ValueType, it returns a copy of the held value, otherwise, if T is a reference
+ to (possibly const qualified) ValueType, it returns a reference to the held
+ value.</simpara></returns>
+
+ <throws><simpara>Overloads taking an
+ <code><classname>any</classname></code> pointer do not
+ throw; overloads taking an
+ <code><classname>any</classname></code> value or reference
+ throws <code><classname>bad_any_cast</classname></code> if
+ unsuccessful.</simpara></throws>
+
+ </overloaded-function>
+ </namespace>
+ </header>
+ </library-reference>
+
+ <section>
+ <title>Acknowledgements</title>
+
+ <para>Doug Gregor ported the documentation to the BoostBook format.</para>
+ </section>
+</library>
diff --git a/include/boost/any.hpp b/include/boost/any.hpp
new file mode 100644
index 0000000..9f6b313
--- /dev/null
+++ b/include/boost/any.hpp
@@ -0,0 +1,337 @@
+// See http://www.boost.org/libs/any for Documentation.
+
+#ifndef BOOST_ANY_INCLUDED
+#define BOOST_ANY_INCLUDED
+
+#if defined(_MSC_VER)
+# pragma once
+#endif
+
+// what: variant type boost::any
+// who: contributed by Kevlin Henney,
+// with features contributed and bugs found by
+// Antony Polukhin, Ed Brey, Mark Rodgers,
+// Peter Dimov, and James Curran
+// when: July 2001, April 2013 - May 2013
+
+#include <algorithm>
+
+#include <boost/config.hpp>
+#include <boost/type_index.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/type_traits/decay.hpp>
+#include <boost/type_traits/remove_cv.hpp>
+#include <boost/type_traits/add_reference.hpp>
+#include <boost/type_traits/is_reference.hpp>
+#include <boost/type_traits/is_const.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/core/addressof.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/is_const.hpp>
+#include <boost/mpl/if.hpp>
+
+namespace boost
+{
+ class any
+ {
+ public: // structors
+
+ any() BOOST_NOEXCEPT
+ : content(0)
+ {
+ }
+
+ template<typename ValueType>
+ any(const ValueType & value)
+ : content(new holder<
+ BOOST_DEDUCED_TYPENAME remove_cv<BOOST_DEDUCED_TYPENAME decay<const ValueType>::type>::type
+ >(value))
+ {
+ }
+
+ any(const any & other)
+ : content(other.content ? other.content->clone() : 0)
+ {
+ }
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ // Move constructor
+ any(any&& other) BOOST_NOEXCEPT
+ : content(other.content)
+ {
+ other.content = 0;
+ }
+
+ // Perfect forwarding of ValueType
+ template<typename ValueType>
+ any(ValueType&& value
+ , typename boost::disable_if<boost::is_same<any&, ValueType> >::type* = 0 // disable if value has type `any&`
+ , typename boost::disable_if<boost::is_const<ValueType> >::type* = 0) // disable if value has type `const ValueType&&`
+ : content(new holder< typename decay<ValueType>::type >(static_cast<ValueType&&>(value)))
+ {
+ }
+#endif
+
+ ~any() BOOST_NOEXCEPT
+ {
+ delete content;
+ }
+
+ public: // modifiers
+
+ any & swap(any & rhs) BOOST_NOEXCEPT
+ {
+ std::swap(content, rhs.content);
+ return *this;
+ }
+
+
+#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
+ template<typename ValueType>
+ any & operator=(const ValueType & rhs)
+ {
+ any(rhs).swap(*this);
+ return *this;
+ }
+
+ any & operator=(any rhs)
+ {
+ any(rhs).swap(*this);
+ return *this;
+ }
+
+#else
+ any & operator=(const any& rhs)
+ {
+ any(rhs).swap(*this);
+ return *this;
+ }
+
+ // move assignement
+ any & operator=(any&& rhs) BOOST_NOEXCEPT
+ {
+ rhs.swap(*this);
+ any().swap(rhs);
+ return *this;
+ }
+
+ // Perfect forwarding of ValueType
+ template <class ValueType>
+ any & operator=(ValueType&& rhs)
+ {
+ any(static_cast<ValueType&&>(rhs)).swap(*this);
+ return *this;
+ }
+#endif
+
+ public: // queries
+
+ bool empty() const BOOST_NOEXCEPT
+ {
+ return !content;
+ }
+
+ void clear() BOOST_NOEXCEPT
+ {
+ any().swap(*this);
+ }
+
+ const boost::typeindex::type_info& type() const BOOST_NOEXCEPT
+ {
+ return content ? content->type() : boost::typeindex::type_id<void>().type_info();
+ }
+
+#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
+ private: // types
+#else
+ public: // types (public so any_cast can be non-friend)
+#endif
+
+ class placeholder
+ {
+ public: // structors
+
+ virtual ~placeholder()
+ {
+ }
+
+ public: // queries
+
+ virtual const boost::typeindex::type_info& type() const BOOST_NOEXCEPT = 0;
+
+ virtual placeholder * clone() const = 0;
+
+ };
+
+ template<typename ValueType>
+ class holder : public placeholder
+ {
+ public: // structors
+
+ holder(const ValueType & value)
+ : held(value)
+ {
+ }
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ holder(ValueType&& value)
+ : held(static_cast< ValueType&& >(value))
+ {
+ }
+#endif
+ public: // queries
+
+ virtual const boost::typeindex::type_info& type() const BOOST_NOEXCEPT
+ {
+ return boost::typeindex::type_id<ValueType>().type_info();
+ }
+
+ virtual placeholder * clone() const
+ {
+ return new holder(held);
+ }
+
+ public: // representation
+
+ ValueType held;
+
+ private: // intentionally left unimplemented
+ holder & operator=(const holder &);
+ };
+
+#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
+
+ private: // representation
+
+ template<typename ValueType>
+ friend ValueType * any_cast(any *) BOOST_NOEXCEPT;
+
+ template<typename ValueType>
+ friend ValueType * unsafe_any_cast(any *) BOOST_NOEXCEPT;
+
+#else
+
+ public: // representation (public so any_cast can be non-friend)
+
+#endif
+
+ placeholder * content;
+
+ };
+
+ inline void swap(any & lhs, any & rhs) BOOST_NOEXCEPT
+ {
+ lhs.swap(rhs);
+ }
+
+ class BOOST_SYMBOL_VISIBLE bad_any_cast :
+#ifndef BOOST_NO_RTTI
+ public std::bad_cast
+#else
+ public std::exception
+#endif
+ {
+ public:
+ virtual const char * what() const BOOST_NOEXCEPT_OR_NOTHROW
+ {
+ return "boost::bad_any_cast: "
+ "failed conversion using boost::any_cast";
+ }
+ };
+
+ template<typename ValueType>
+ ValueType * any_cast(any * operand) BOOST_NOEXCEPT
+ {
+ return operand && operand->type() == boost::typeindex::type_id<ValueType>()
+ ? boost::addressof(
+ static_cast<any::holder<BOOST_DEDUCED_TYPENAME remove_cv<ValueType>::type> *>(operand->content)->held
+ )
+ : 0;
+ }
+
+ template<typename ValueType>
+ inline const ValueType * any_cast(const any * operand) BOOST_NOEXCEPT
+ {
+ return any_cast<ValueType>(const_cast<any *>(operand));
+ }
+
+ template<typename ValueType>
+ ValueType any_cast(any & operand)
+ {
+ typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref;
+
+
+ nonref * result = any_cast<nonref>(boost::addressof(operand));
+ if(!result)
+ boost::throw_exception(bad_any_cast());
+
+ // Attempt to avoid construction of a temporary object in cases when
+ // `ValueType` is not a reference. Example:
+ // `static_cast<std::string>(*result);`
+ // which is equal to `std::string(*result);`
+ typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_<
+ boost::is_reference<ValueType>,
+ ValueType,
+ BOOST_DEDUCED_TYPENAME boost::add_reference<ValueType>::type
+ >::type ref_type;
+
+#ifdef BOOST_MSVC
+# pragma warning(push)
+# pragma warning(disable: 4172) // "returning address of local variable or temporary" but *result is not local!
+#endif
+ return static_cast<ref_type>(*result);
+#ifdef BOOST_MSVC
+# pragma warning(pop)
+#endif
+ }
+
+ template<typename ValueType>
+ inline ValueType any_cast(const any & operand)
+ {
+ typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref;
+ return any_cast<const nonref &>(const_cast<any &>(operand));
+ }
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ template<typename ValueType>
+ inline ValueType any_cast(any&& operand)
+ {
+ BOOST_STATIC_ASSERT_MSG(
+ boost::is_rvalue_reference<ValueType&&>::value /*true if ValueType is rvalue or just a value*/
+ || boost::is_const< typename boost::remove_reference<ValueType>::type >::value,
+ "boost::any_cast shall not be used for getting nonconst references to temporary objects"
+ );
+ return any_cast<ValueType>(operand);
+ }
+#endif
+
+
+ // Note: The "unsafe" versions of any_cast are not part of the
+ // public interface and may be removed at any time. They are
+ // required where we know what type is stored in the any and can't
+ // use typeid() comparison, e.g., when our types may travel across
+ // different shared libraries.
+ template<typename ValueType>
+ inline ValueType * unsafe_any_cast(any * operand) BOOST_NOEXCEPT
+ {
+ return boost::addressof(
+ static_cast<any::holder<ValueType> *>(operand->content)->held
+ );
+ }
+
+ template<typename ValueType>
+ inline const ValueType * unsafe_any_cast(const any * operand) BOOST_NOEXCEPT
+ {
+ return unsafe_any_cast<ValueType>(const_cast<any *>(operand));
+ }
+}
+
+// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved.
+//
+// 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)
+
+#endif
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..18d07f1
--- /dev/null
+++ b/index.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0; URL=../../doc/html/any.html">
+</head>
+<body>
+Automatic redirection failed, please go to
+<a href="../../doc/html/any.html">../../doc/html/any.html</a>
+<hr>
+<p>© Copyright Beman Dawes, 2001</p>
+<p> Distributed under the Boost Software
+License, Version 1.0. (See accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
+www.boost.org/LICENSE_1_0.txt</a>)</p>
+</body>
+</html>
\ No newline at end of file
diff --git a/meta/libraries.json b/meta/libraries.json
new file mode 100644
index 0000000..3e6dd90
--- /dev/null
+++ b/meta/libraries.json
@@ -0,0 +1,14 @@
+{
+ "key": "any",
+ "name": "Any",
+ "authors": [
+ "Kevlin Henney"
+ ],
+ "description": "Safe, generic container for single values of different value types.",
+ "category": [
+ "Data"
+ ],
+ "maintainers": [
+ "Antony Polukhin <antoshkka -at- gmail.com>"
+ ]
+}
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
new file mode 100644
index 0000000..ce2ba55
--- /dev/null
+++ b/test/Jamfile.v2
@@ -0,0 +1,20 @@
+# Copyright Vladimur Prus 2005. Use, modification and
+# distribution is subject to 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)
+#
+# For more information, see http://www.boost.org/libs/any
+#
+
+test-suite any :
+ [ run any_test.cpp ]
+ [ run any_test.cpp : : : <rtti>off <define>BOOST_NO_RTTI <define>BOOST_NO_TYPEID : any_test_no_rtti ]
+ [ run any_test_rv.cpp ]
+ [ run any_test_rv.cpp : : : <rtti>off <define>BOOST_NO_RTTI <define>BOOST_NO_TYPEID : any_test_rv_no_rtti ]
+ [ run any_test_mplif.cpp ]
+ [ compile-fail any_cast_cv_failed.cpp ]
+ [ compile-fail any_test_temporary_to_ref_failed.cpp ]
+ [ compile-fail any_test_cv_to_rv_failed.cpp ]
+ ;
+
+
diff --git a/test/any_cast_cv_failed.cpp b/test/any_cast_cv_failed.cpp
new file mode 100644
index 0000000..860240f
--- /dev/null
+++ b/test/any_cast_cv_failed.cpp
@@ -0,0 +1,14 @@
+// Copyright 2006 Alexander Nasonov.
+//
+// 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)
+
+#include <boost/any.hpp>
+
+int main()
+{
+ boost::any const a;
+ boost::any_cast<int&>(a);
+}
+
diff --git a/test/any_test.cpp b/test/any_test.cpp
new file mode 100644
index 0000000..4c65b0e
--- /dev/null
+++ b/test/any_test.cpp
@@ -0,0 +1,405 @@
+// what: unit tests for variant type boost::any
+// who: contributed by Kevlin Henney
+// when: July 2001, 2013, 2014
+// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.95
+
+#include <cstdlib>
+#include <string>
+#include <vector>
+#include <utility>
+
+#include <boost/any.hpp>
+#include "test.hpp"
+
+namespace any_tests
+{
+ typedef test<const char *, void (*)()> test_case;
+ typedef const test_case * test_case_iterator;
+
+ extern const test_case_iterator begin, end;
+}
+
+int main()
+{
+ using namespace any_tests;
+ tester<test_case_iterator> test_suite(begin, end);
+ return test_suite() ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
+namespace any_tests // test suite
+{
+ void test_default_ctor();
+ void test_converting_ctor();
+ void test_copy_ctor();
+ void test_copy_assign();
+ void test_converting_assign();
+ void test_bad_cast();
+ void test_swap();
+ void test_null_copying();
+ void test_cast_to_reference();
+ void test_with_array();
+ void test_with_func();
+ void test_clear();
+ void test_vectors();
+ void test_addressof();
+
+ const test_case test_cases[] =
+ {
+ { "default construction", test_default_ctor },
+ { "single argument construction", test_converting_ctor },
+ { "copy construction", test_copy_ctor },
+ { "copy assignment operator", test_copy_assign },
+ { "converting assignment operator", test_converting_assign },
+ { "failed custom keyword cast", test_bad_cast },
+ { "swap member function", test_swap },
+ { "copying operations on a null", test_null_copying },
+ { "cast to reference types", test_cast_to_reference },
+ { "storing an array inside", test_with_array },
+ { "implicit cast of returned value",test_with_func },
+ { "clear() methods", test_clear },
+ { "testing with vectors", test_vectors },
+ { "class with operator&()", test_addressof }
+ };
+
+ const test_case_iterator begin = test_cases;
+ const test_case_iterator end =
+ test_cases + (sizeof test_cases / sizeof *test_cases);
+
+
+
+ struct copy_counter
+ {
+
+ public:
+
+ copy_counter() {}
+ copy_counter(const copy_counter&) { ++count; }
+ copy_counter& operator=(const copy_counter&) { ++count; return *this; }
+ static int get_count() { return count; }
+
+ private:
+
+ static int count;
+
+ };
+
+ int copy_counter::count = 0;
+}
+
+namespace any_tests // test definitions
+{
+ using namespace boost;
+
+ void test_default_ctor()
+ {
+ const any value;
+
+ check_true(value.empty(), "empty");
+ check_null(any_cast<int>(&value), "any_cast<int>");
+ check_equal(value.type(), boost::typeindex::type_id<void>(), "type");
+ }
+
+ void test_converting_ctor()
+ {
+ std::string text = "test message";
+ any value = text;
+
+ check_false(value.empty(), "empty");
+ check_equal(value.type(), boost::typeindex::type_id<std::string>(), "type");
+ check_null(any_cast<int>(&value), "any_cast<int>");
+ check_non_null(any_cast<std::string>(&value), "any_cast<std::string>");
+ check_equal(
+ any_cast<std::string>(value), text,
+ "comparing cast copy against original text");
+ check_unequal(
+ any_cast<std::string>(&value), &text,
+ "comparing address in copy against original text");
+ }
+
+ void test_copy_ctor()
+ {
+ std::string text = "test message";
+ any original = text, copy = original;
+
+ check_false(copy.empty(), "empty");
+ check_equal(boost::typeindex::type_index(original.type()), copy.type(), "type");
+ check_equal(
+ any_cast<std::string>(original), any_cast<std::string>(copy),
+ "comparing cast copy against original");
+ check_equal(
+ text, any_cast<std::string>(copy),
+ "comparing cast copy against original text");
+ check_unequal(
+ any_cast<std::string>(&original),
+ any_cast<std::string>(©),
+ "comparing address in copy against original");
+ }
+
+ void test_copy_assign()
+ {
+ std::string text = "test message";
+ any original = text, copy;
+ any * assign_result = &(copy = original);
+
+ check_false(copy.empty(), "empty");
+ check_equal(boost::typeindex::type_index(original.type()), copy.type(), "type");
+ check_equal(
+ any_cast<std::string>(original), any_cast<std::string>(copy),
+ "comparing cast copy against cast original");
+ check_equal(
+ text, any_cast<std::string>(copy),
+ "comparing cast copy against original text");
+ check_unequal(
+ any_cast<std::string>(&original),
+ any_cast<std::string>(©),
+ "comparing address in copy against original");
+ check_equal(assign_result, ©, "address of assignment result");
+ }
+
+ void test_converting_assign()
+ {
+ std::string text = "test message";
+ any value;
+ any * assign_result = &(value = text);
+
+ check_false(value.empty(), "type");
+ check_equal(value.type(), boost::typeindex::type_id<std::string>(), "type");
+ check_null(any_cast<int>(&value), "any_cast<int>");
+ check_non_null(any_cast<std::string>(&value), "any_cast<std::string>");
+ check_equal(
+ any_cast<std::string>(value), text,
+ "comparing cast copy against original text");
+ check_unequal(
+ any_cast<std::string>(&value),
+ &text,
+ "comparing address in copy against original text");
+ check_equal(assign_result, &value, "address of assignment result");
+ }
+
+ void test_bad_cast()
+ {
+ std::string text = "test message";
+ any value = text;
+
+ TEST_CHECK_THROW(
+ any_cast<const char *>(value),
+ bad_any_cast,
+ "any_cast to incorrect type");
+ }
+
+ void test_swap()
+ {
+ std::string text = "test message";
+ any original = text, swapped;
+ std::string * original_ptr = any_cast<std::string>(&original);
+ any * swap_result = &original.swap(swapped);
+
+ check_true(original.empty(), "empty on original");
+ check_false(swapped.empty(), "empty on swapped");
+ check_equal(swapped.type(), boost::typeindex::type_id<std::string>(), "type");
+ check_equal(
+ text, any_cast<std::string>(swapped),
+ "comparing swapped copy against original text");
+ check_non_null(original_ptr, "address in pre-swapped original");
+ check_equal(
+ original_ptr,
+ any_cast<std::string>(&swapped),
+ "comparing address in swapped against original");
+ check_equal(swap_result, &original, "address of swap result");
+
+ any copy1 = copy_counter();
+ any copy2 = copy_counter();
+ int count = copy_counter::get_count();
+ swap(copy1, copy2);
+ check_equal(count, copy_counter::get_count(), "checking that free swap doesn't make any copies.");
+ }
+
+ void test_null_copying()
+ {
+ const any null;
+ any copied = null, assigned;
+ assigned = null;
+
+ check_true(null.empty(), "empty on null");
+ check_true(copied.empty(), "empty on copied");
+ check_true(assigned.empty(), "empty on copied");
+ }
+
+ void test_cast_to_reference()
+ {
+ any a(137);
+ const any b(a);
+
+ int & ra = any_cast<int &>(a);
+ int const & ra_c = any_cast<int const &>(a);
+ int volatile & ra_v = any_cast<int volatile &>(a);
+ int const volatile & ra_cv = any_cast<int const volatile&>(a);
+
+ check_true(
+ &ra == &ra_c && &ra == &ra_v && &ra == &ra_cv,
+ "cv references to same obj");
+
+ int const & rb_c = any_cast<int const &>(b);
+ int const volatile & rb_cv = any_cast<int const volatile &>(b);
+
+ check_true(&rb_c == &rb_cv, "cv references to copied const obj");
+ check_true(&ra != &rb_c, "copies hold different objects");
+
+ ++ra;
+ int incremented = any_cast<int>(a);
+ check_true(incremented == 138, "increment by reference changes value");
+
+ TEST_CHECK_THROW(
+ any_cast<char &>(a),
+ bad_any_cast,
+ "any_cast to incorrect reference type");
+
+ TEST_CHECK_THROW(
+ any_cast<const char &>(b),
+ bad_any_cast,
+ "any_cast to incorrect const reference type");
+ }
+
+ void test_with_array()
+ {
+ any value1("Char array");
+ any value2;
+ value2 = "Char array";
+
+ check_false(value1.empty(), "type");
+ check_false(value2.empty(), "type");
+
+ check_equal(value1.type(), boost::typeindex::type_id<const char*>(), "type");
+ check_equal(value2.type(), boost::typeindex::type_id<const char*>(), "type");
+
+ check_non_null(any_cast<const char*>(&value1), "any_cast<const char*>");
+ check_non_null(any_cast<const char*>(&value2), "any_cast<const char*>");
+ }
+
+ const std::string& returning_string1()
+ {
+ static const std::string ret("foo");
+ return ret;
+ }
+
+ std::string returning_string2()
+ {
+ static const std::string ret("foo");
+ return ret;
+ }
+
+ void test_with_func()
+ {
+ std::string s;
+ s = any_cast<std::string>(returning_string1());
+ s = any_cast<const std::string&>(returning_string1());
+
+ s = any_cast<std::string>(returning_string2());
+ s = any_cast<const std::string&>(returning_string2());
+
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+#if !defined(__INTEL_COMPILER) && !defined(__ICL) && (!defined(_MSC_VER) || _MSC_VER != 1600)
+ // Intel compiler thinks that it must choose the `any_cast(const any&)` function
+ // instead of the `any_cast(const any&&)`.
+ // Bug was not reported because of missing premier support account + annoying
+ // registrations requirements.
+
+ // MSVC-10 had a bug:
+ //
+ // any.hpp(291) : error C2440: 'return' : cannot convert.
+ // Conversion loses qualifiers
+ // any_test.cpp(304) : see reference to function template instantiation
+ //
+ // This issue was fixed in MSVC-11.
+
+ s = any_cast<std::string&&>(returning_string1());
+#endif
+
+ s = any_cast<std::string&&>(returning_string2());
+#endif
+ }
+
+
+ void test_clear()
+ {
+ std::string text = "test message";
+ any value = text;
+
+ check_false(value.empty(), "empty");
+
+ value.clear();
+ check_true(value.empty(), "non-empty after clear");
+
+ value.clear();
+ check_true(value.empty(), "non-empty after second clear");
+
+ value = text;
+ check_false(value.empty(), "empty");
+
+ value.clear();
+ check_true(value.empty(), "non-empty after clear");
+ }
+
+ // Following tests cover the case from #9462
+ // https://svn.boost.org/trac/boost/ticket/9462
+ boost::any makeVec()
+ {
+ return std::vector<int>(100 /*size*/, 7 /*value*/);
+ }
+
+ void test_vectors()
+ {
+ const std::vector<int>& vec = boost::any_cast<std::vector<int> >(makeVec());
+ check_equal(vec.size(), 100u, "size of vector extracted from boost::any");
+ check_equal(vec.back(), 7, "back value of vector extracted from boost::any");
+ check_equal(vec.front(), 7, "front value of vector extracted from boost::any");
+
+ std::vector<int> vec1 = boost::any_cast<std::vector<int> >(makeVec());
+ check_equal(vec1.size(), 100u, "size of second vector extracted from boost::any");
+ check_equal(vec1.back(), 7, "back value of second vector extracted from boost::any");
+ check_equal(vec1.front(), 7, "front value of second vector extracted from boost::any");
+
+ }
+
+ template<typename T>
+ class class_with_address_op {
+ public:
+ class_with_address_op(const T* p)
+ : ptr(p)
+ {}
+
+ const T** operator &() {
+ return &ptr;
+ }
+
+ const T* get() const {
+ return ptr;
+ }
+
+ private:
+ const T* ptr;
+ };
+
+ void test_addressof()
+ {
+ int val = 10;
+ const int* ptr = &val;
+ class_with_address_op<int> obj(ptr);
+ boost::any test_val(obj);
+
+ class_with_address_op<int> returned_obj = boost::any_cast<class_with_address_op<int> >(test_val);
+ check_equal(&val, returned_obj.get(), "any_cast incorrectly works with type that has operator&(): addresses differ");
+
+ check_true(!!boost::any_cast<class_with_address_op<int> >(&test_val), "any_cast incorrectly works with type that has operator&()");
+ check_equal(boost::unsafe_any_cast<class_with_address_op<int> >(&test_val)->get(), ptr, "unsafe_any_cast incorrectly works with type that has operator&()");
+ }
+
+}
+
+// Copyright Kevlin Henney, 2000, 2001. All rights reserved.
+// Copyright Antony Polukhin, 2013-2017.
+//
+// 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)
+//
diff --git a/test/any_test_cv_to_rv_failed.cpp b/test/any_test_cv_to_rv_failed.cpp
new file mode 100644
index 0000000..a4a34ed
--- /dev/null
+++ b/test/any_test_cv_to_rv_failed.cpp
@@ -0,0 +1,39 @@
+// Unit test for boost::any.
+//
+// See http://www.boost.org for most recent version, including documentation.
+//
+// Copyright Antony Polukhin, 2013-2014.
+//
+// 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).
+
+#include <cstdlib>
+#include <string>
+#include <utility>
+
+#include <boost/any.hpp>
+#include "test.hpp"
+#include <boost/move/move.hpp>
+
+#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
+
+int main()
+{
+ BOOST_STATIC_ASSERT(false);
+ return EXIT_SUCCESS;
+}
+
+#else
+
+
+int main()
+{
+ boost::any const cvalue(10);
+ int i = boost::any_cast<int&&>(cvalue);
+ (void)i;
+ return EXIT_SUCCESS;
+}
+
+#endif
+
diff --git a/test/any_test_mplif.cpp b/test/any_test_mplif.cpp
new file mode 100644
index 0000000..b0da7c1
--- /dev/null
+++ b/test/any_test_mplif.cpp
@@ -0,0 +1,19 @@
+// Copyright Antony Polukhin, 2017.
+//
+// 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)
+
+// This tests the issue from https://svn.boost.org/trac/boost/ticket/12052
+
+#include <iostream>
+#include <boost/any.hpp>
+
+int main() {
+ boost::any a = 1;
+ std::cout << boost::any_cast<int>(a) << '\n';
+ a = 3.14;
+ std::cout << boost::any_cast<double>(a) << '\n';
+ a = true;
+ std::cout << std::boolalpha << boost::any_cast<bool>(a) << '\n';
+}
diff --git a/test/any_test_rv.cpp b/test/any_test_rv.cpp
new file mode 100644
index 0000000..0571c70
--- /dev/null
+++ b/test/any_test_rv.cpp
@@ -0,0 +1,331 @@
+// Unit test for boost::any.
+//
+// See http://www.boost.org for most recent version, including documentation.
+//
+// Copyright Antony Polukhin, 2013-2014.
+//
+// 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).
+
+#include <cstdlib>
+#include <string>
+#include <utility>
+
+#include <boost/any.hpp>
+#include "test.hpp"
+#include <boost/move/move.hpp>
+
+#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
+
+int main()
+{
+ return EXIT_SUCCESS;
+}
+
+#else
+
+namespace any_tests
+{
+ typedef test<const char *, void (*)()> test_case;
+ typedef const test_case * test_case_iterator;
+
+ extern const test_case_iterator begin, end;
+}
+
+int main()
+{
+ using namespace any_tests;
+ tester<test_case_iterator> test_suite(begin, end);
+ return test_suite() ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
+namespace any_tests // test suite
+{
+ void test_move_construction();
+ void test_move_assignment();
+ void test_copy_construction();
+ void test_copy_assignment();
+
+ void test_move_construction_from_value();
+ void test_move_assignment_from_value();
+ void test_copy_construction_from_value();
+ void test_copy_assignment_from_value();
+ void test_construction_from_const_any_rv();
+ void test_cast_to_rv();
+
+
+ const test_case test_cases[] =
+ {
+ { "move construction of any", test_move_construction },
+ { "move assignment of any", test_move_assignment },
+ { "copy construction of any", test_copy_construction },
+ { "copy assignment of any", test_copy_assignment },
+
+ { "move construction from value", test_move_construction_from_value },
+ { "move assignment from value", test_move_assignment_from_value },
+ { "copy construction from value", test_copy_construction_from_value },
+ { "copy assignment from value", test_copy_assignment_from_value },
+ { "constructing from const any&&", test_construction_from_const_any_rv },
+ { "casting to rvalue reference", test_cast_to_rv }
+ };
+
+ const test_case_iterator begin = test_cases;
+ const test_case_iterator end =
+ test_cases + (sizeof test_cases / sizeof *test_cases);
+
+
+ class move_copy_conting_class {
+ public:
+ static unsigned int moves_count;
+ static unsigned int copy_count;
+
+ move_copy_conting_class(){}
+ move_copy_conting_class(move_copy_conting_class&& /*param*/) {
+ ++ moves_count;
+ }
+
+ move_copy_conting_class& operator=(move_copy_conting_class&& /*param*/) {
+ ++ moves_count;
+ return *this;
+ }
+
+ move_copy_conting_class(const move_copy_conting_class&) {
+ ++ copy_count;
+ }
+ move_copy_conting_class& operator=(const move_copy_conting_class& /*param*/) {
+ ++ copy_count;
+ return *this;
+ }
+ };
+
+ unsigned int move_copy_conting_class::moves_count = 0;
+ unsigned int move_copy_conting_class::copy_count = 0;
+}
+
+namespace any_tests // test definitions
+{
+ using namespace boost;
+
+ void test_move_construction()
+ {
+ any value0 = move_copy_conting_class();
+ move_copy_conting_class::copy_count = 0;
+ move_copy_conting_class::moves_count = 0;
+ any value(boost::move(value0));
+
+ check(value0.empty(), "moved away value is empty");
+ check_false(value.empty(), "empty");
+ check_equal(value.type(), typeindex::type_id<move_copy_conting_class>(), "type");
+ check_non_null(any_cast<move_copy_conting_class>(&value), "any_cast<move_copy_conting_class>");
+ check_equal(
+ move_copy_conting_class::copy_count, 0u,
+ "checking copy counts");
+ check_equal(
+ move_copy_conting_class::moves_count, 0u,
+ "checking move counts");
+ }
+
+ void test_move_assignment()
+ {
+ any value0 = move_copy_conting_class();
+ any value = move_copy_conting_class();
+ move_copy_conting_class::copy_count = 0;
+ move_copy_conting_class::moves_count = 0;
+ value = boost::move(value0);
+
+ check(value0.empty(), "moved away is empty");
+ check_false(value.empty(), "empty");
+ check_equal(value.type(), typeindex::type_id<move_copy_conting_class>(), "type");
+ check_non_null(any_cast<move_copy_conting_class>(&value), "any_cast<move_copy_conting_class>");
+ check_equal(
+ move_copy_conting_class::copy_count, 0u,
+ "checking copy counts");
+ check_equal(
+ move_copy_conting_class::moves_count, 0u,
+ "checking move counts");
+ }
+
+ void test_copy_construction()
+ {
+ any value0 = move_copy_conting_class();
+ move_copy_conting_class::copy_count = 0;
+ move_copy_conting_class::moves_count = 0;
+ any value(value0);
+
+ check_false(value0.empty(), "copyed value is not empty");
+ check_false(value.empty(), "empty");
+ check_equal(value.type(), typeindex::type_id<move_copy_conting_class>(), "type");
+ check_non_null(any_cast<move_copy_conting_class>(&value), "any_cast<move_copy_conting_class>");
+ check_equal(
+ move_copy_conting_class::copy_count, 1u,
+ "checking copy counts");
+ check_equal(
+ move_copy_conting_class::moves_count, 0u,
+ "checking move counts");
+ }
+
+ void test_copy_assignment()
+ {
+ any value0 = move_copy_conting_class();
+ any value = move_copy_conting_class();
+ move_copy_conting_class::copy_count = 0;
+ move_copy_conting_class::moves_count = 0;
+ value = value0;
+
+ check_false(value0.empty(), "copyied value is not empty");
+ check_false(value.empty(), "empty");
+ check_equal(value.type(), typeindex::type_id<move_copy_conting_class>(), "type");
+ check_non_null(any_cast<move_copy_conting_class>(&value), "any_cast<move_copy_conting_class>");
+ check_equal(
+ move_copy_conting_class::copy_count, 1u,
+ "checking copy counts");
+ check_equal(
+ move_copy_conting_class::moves_count, 0u,
+ "checking move counts");
+ }
+
+ void test_move_construction_from_value()
+ {
+ move_copy_conting_class value0;
+ move_copy_conting_class::copy_count = 0;
+ move_copy_conting_class::moves_count = 0;
+#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ any value(boost::move(value0));
+#else
+ any value(value0);
+#endif
+
+ check_false(value.empty(), "empty");
+ check_equal(value.type(), typeindex::type_id<move_copy_conting_class>(), "type");
+ check_non_null(any_cast<move_copy_conting_class>(&value), "any_cast<move_copy_conting_class>");
+
+#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ check_equal(
+ move_copy_conting_class::copy_count, 0u,
+ "checking copy counts");
+ check_equal(
+ move_copy_conting_class::moves_count, 1u,
+ "checking move counts");
+#endif
+
+ }
+
+ void test_move_assignment_from_value()
+ {
+ move_copy_conting_class value0;
+ any value;
+ move_copy_conting_class::copy_count = 0;
+ move_copy_conting_class::moves_count = 0;
+#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ value = boost::move(value0);
+#else
+ value = value0;
+#endif
+
+ check_false(value.empty(), "empty");
+ check_equal(value.type(), typeindex::type_id<move_copy_conting_class>(), "type");
+ check_non_null(any_cast<move_copy_conting_class>(&value), "any_cast<move_copy_conting_class>");
+
+#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ check_equal(
+ move_copy_conting_class::copy_count, 0u,
+ "checking copy counts");
+ check_equal(
+ move_copy_conting_class::moves_count, 1u,
+ "checking move counts");
+#endif
+
+ }
+
+ void test_copy_construction_from_value()
+ {
+ move_copy_conting_class value0;
+ move_copy_conting_class::copy_count = 0;
+ move_copy_conting_class::moves_count = 0;
+ any value(value0);
+
+ check_false(value.empty(), "empty");
+ check_equal(value.type(), typeindex::type_id<move_copy_conting_class>(), "type");
+ check_non_null(any_cast<move_copy_conting_class>(&value), "any_cast<move_copy_conting_class>");
+
+ check_equal(
+ move_copy_conting_class::copy_count, 1u,
+ "checking copy counts");
+ check_equal(
+ move_copy_conting_class::moves_count, 0u,
+ "checking move counts");
+ }
+
+ void test_copy_assignment_from_value()
+ {
+ move_copy_conting_class value0;
+ any value;
+ move_copy_conting_class::copy_count = 0;
+ move_copy_conting_class::moves_count = 0;
+ value = value0;
+
+ check_false(value.empty(), "empty");
+ check_equal(value.type(), typeindex::type_id<move_copy_conting_class>(), "type");
+ check_non_null(any_cast<move_copy_conting_class>(&value), "any_cast<move_copy_conting_class>");
+
+ check_equal(
+ move_copy_conting_class::copy_count, 1u,
+ "checking copy counts");
+ check_equal(
+ move_copy_conting_class::moves_count, 0u,
+ "checking move counts");
+ }
+
+ const any helper_method() {
+ return true;
+ }
+
+ const bool helper_method1() {
+ return true;
+ }
+
+ void test_construction_from_const_any_rv()
+ {
+ any values[] = {helper_method(), helper_method1() };
+ (void)values;
+ }
+
+ void test_cast_to_rv()
+ {
+ move_copy_conting_class value0;
+ any value;
+ value = value0;
+ move_copy_conting_class::copy_count = 0;
+ move_copy_conting_class::moves_count = 0;
+
+ move_copy_conting_class value1 = any_cast<move_copy_conting_class&&>(value);
+
+ check_equal(
+ move_copy_conting_class::copy_count, 0u,
+ "checking copy counts");
+ check_equal(
+ move_copy_conting_class::moves_count, 1u,
+ "checking move counts");
+ (void)value1;
+/* Following code shall fail to compile
+ const any cvalue = value0;
+ move_copy_conting_class::copy_count = 0;
+ move_copy_conting_class::moves_count = 0;
+
+ move_copy_conting_class value2 = any_cast<move_copy_conting_class&&>(cvalue);
+
+ check_equal(
+ move_copy_conting_class::copy_count, 1u,
+ "checking copy counts");
+ check_equal(
+ move_copy_conting_class::moves_count, 0u,
+ "checking move counts");
+ (void)value2;
+*/
+ }
+
+}
+
+#endif
+
diff --git a/test/any_test_temporary_to_ref_failed.cpp b/test/any_test_temporary_to_ref_failed.cpp
new file mode 100644
index 0000000..daa42ca
--- /dev/null
+++ b/test/any_test_temporary_to_ref_failed.cpp
@@ -0,0 +1,38 @@
+// Unit test for boost::any.
+//
+// See http://www.boost.org for most recent version, including documentation.
+//
+// Copyright Antony Polukhin, 2013-2014.
+//
+// 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).
+
+#include <cstdlib>
+#include <string>
+#include <utility>
+
+#include <boost/any.hpp>
+#include "test.hpp"
+#include <boost/move/move.hpp>
+
+#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
+
+int main()
+{
+ BOOST_STATIC_ASSERT(false);
+ return EXIT_SUCCESS;
+}
+
+#else
+
+
+int main()
+{
+ int i = boost::any_cast<int&>(10);
+ (void)i;
+ return EXIT_SUCCESS;
+}
+
+#endif
+
diff --git a/test/appveyor.yml b/test/appveyor.yml
new file mode 100644
index 0000000..7da83ce
--- /dev/null
+++ b/test/appveyor.yml
@@ -0,0 +1,60 @@
+# Use, modification, and distribution are
+# subject to 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)
+#
+# Copyright Antony Polukhin 2016-2017.
+
+#
+# See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file
+# and how it can be used with Boost libraries.
+#
+# File revision #5
+
+init:
+ - set BRANCH_TO_TEST=%APPVEYOR_REPO_BRANCH% # Change to branch you wish to test. Use %APPVEYOR_REPO_BRANCH% for current branch.
+ - set BOOST_REMOVE=any # Remove this folder from lib from full clone of Boost. If you are testing `any` repo, write here `any`.
+
+###############################################################################################################
+# From this point and below code is same for all the Boost libs
+###############################################################################################################
+
+version: 1.64.{build}-{branch}
+
+# branches to build
+branches:
+ except:
+ - gh-pages
+
+skip_tags: true
+
+before_build:
+ - set PATH=%PATH%;C:\\MinGW\\bin
+ - echo "Testing %APPVEYOR_PROJECT_NAME%"
+ # Cloning Boost libraries (fast nondeep cloning)
+ - set BOOST=C:/boost-local
+ - git init %BOOST%
+ - cd %BOOST%
+ - git remote add --no-tags -t %BRANCH_TO_TEST% origin https://github.com/boostorg/boost.git
+ - git fetch --depth=1
+ - git checkout %BRANCH_TO_TEST%
+ - git submodule update --init --merge --jobs 16
+ - git remote set-branches --add origin %BRANCH_TO_TEST%
+ #- git pull --recurse-submodules # Updaes submodules to most recent version. Not required
+ - rm -rf %BOOST%/libs/%BOOST_REMOVE%
+ - mv %APPVEYOR_BUILD_FOLDER% %BOOST%/libs/%APPVEYOR_PROJECT_NAME%
+
+build_script:
+ - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
+ - bootstrap.bat
+ - b2.exe headers
+ - cd %BOOST%/libs/%APPVEYOR_PROJECT_NAME%/test
+
+after_build:
+before_test:
+test_script:
+ - ..\..\..\b2.exe address-model=32 architecture=x86 toolset=msvc,gcc cxxflags="-DBOOST_TRAVISCI_BUILD" -sBOOST_BUILD_PATH=.
+
+after_test:
+on_success:
+on_failure:
+on_finish:
diff --git a/test/test.hpp b/test/test.hpp
new file mode 100644
index 0000000..65a0c81
--- /dev/null
+++ b/test/test.hpp
@@ -0,0 +1,321 @@
+// what: simple unit test framework
+// who: developed by Kevlin Henney
+// when: November 2000
+// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.91
+
+#ifndef TEST_INCLUDED
+#define TEST_INCLUDED
+
+#include <boost/config.hpp>
+#include <exception>
+#include <iostream>
+#ifdef BOOST_NO_STRINGSTREAM
+#include <strstream> // for out-of-the-box g++ pre-2.95.3
+#else
+#include <sstream>
+#endif
+#include <string>
+
+namespace any_tests // test tuple comprises name and nullary function (object)
+{
+ template<typename string_type, typename function_type>
+ struct test
+ {
+ string_type name;
+ function_type action;
+
+ static test make(string_type name, function_type action)
+ {
+ test result; // MSVC aggreggate initializer bugs
+ result.name = name;
+ result.action = action;
+ return result;
+ }
+ };
+}
+
+namespace any_tests // failure exception used to indicate checked test failures
+{
+ class failure : public std::exception
+ {
+ public: // struction (default cases are OK)
+
+ failure(const std::string & why) throw()
+ : reason(why)
+ {
+ }
+
+ ~failure() throw() {}
+
+ public: // usage
+
+ virtual const char * what() const throw()
+ {
+ return reason.c_str();
+ }
+
+ private: // representation
+
+ std::string reason;
+
+ };
+}
+
+namespace any_tests // not_implemented exception used to mark unimplemented tests
+{
+ class not_implemented : public std::exception
+ {
+ public: // usage (default ctor and dtor are OK)
+
+ virtual const char * what() const throw()
+ {
+ return "not implemented";
+ }
+
+ };
+}
+
+namespace any_tests // test utilities
+{
+ inline void check(bool condition, const std::string & description)
+ {
+ if(!condition)
+ {
+ throw failure(description);
+ }
+ }
+
+ inline void check_true(bool value, const std::string & description)
+ {
+ check(value, "expected true: " + description);
+ }
+
+ inline void check_false(bool value, const std::string & description)
+ {
+ check(!value, "expected false: " + description);
+ }
+
+ template<typename lhs_type, typename rhs_type>
+ void check_equal(
+ const lhs_type & lhs, const rhs_type & rhs,
+ const std::string & description)
+ {
+ check(lhs == rhs, "expected equal values: " + description);
+ }
+
+ template<typename lhs_type, typename rhs_type>
+ void check_unequal(
+ const lhs_type & lhs, const rhs_type & rhs,
+ const std::string & description)
+ {
+ check(lhs != rhs, "expected unequal values: " + description);
+ }
+
+ inline void check_null(const void * ptr, const std::string & description)
+ {
+ check(!ptr, "expected null pointer: " + description);
+ }
+
+ inline void check_non_null(const void * ptr, const std::string & description)
+ {
+ check(ptr != 0, "expected non-null pointer: " + description);
+ }
+}
+
+#define TEST_CHECK_THROW(expression, exception, description) \
+ try \
+ { \
+ expression; \
+ throw ::any_tests::failure(description); \
+ } \
+ catch(exception &) \
+ { \
+ }
+
+namespace any_tests // memory tracking (enabled if test new and delete linked in)
+{
+ class allocations
+ {
+ public: // singleton access
+
+ static allocations & instance()
+ {
+ static allocations singleton;
+ return singleton;
+ }
+
+ public: // logging
+
+ void clear()
+ {
+ alloc_count = dealloc_count = 0;
+ }
+
+ void allocation()
+ {
+ ++alloc_count;
+ }
+
+ void deallocation()
+ {
+ ++dealloc_count;
+ }
+
+ public: // reporting
+
+ unsigned long allocated() const
+ {
+ return alloc_count;
+ }
+
+ unsigned long deallocated() const
+ {
+ return dealloc_count;
+ }
+
+ bool balanced() const
+ {
+ return alloc_count == dealloc_count;
+ }
+
+ private: // structors (default dtor is fine)
+
+ allocations()
+ : alloc_count(0), dealloc_count(0)
+ {
+ }
+
+ private: // prevention
+
+ allocations(const allocations &);
+ allocations & operator=(const allocations &);
+
+ private: // state
+
+ unsigned long alloc_count, dealloc_count;
+
+ };
+}
+
+namespace any_tests // tester is the driver class for a sequence of tests
+{
+ template<typename test_iterator>
+ class tester
+ {
+ public: // structors (default destructor is OK)
+
+ tester(test_iterator first_test, test_iterator after_last_test)
+ : begin(first_test), end(after_last_test)
+ {
+ }
+
+ public: // usage
+
+ bool operator()(); // returns true if all tests passed
+
+ private: // representation
+
+ test_iterator begin, end;
+
+ private: // prevention
+
+ tester(const tester &);
+ tester &operator=(const tester &);
+
+ };
+
+#if defined(__GNUC__) && defined(__SGI_STL_PORT) && (__GNUC__ < 3)
+ // function scope using declarations don't work:
+ using namespace std;
+#endif
+
+ template<typename test_iterator>
+ bool tester<test_iterator>::operator()()
+ {
+ using std::cerr;
+ using std::endl;
+ using std::ends;
+ using std::exception;
+ using std::flush;
+ using std::string;
+
+ unsigned long passed = 0, failed = 0, unimplemented = 0;
+
+ for(test_iterator current = begin; current != end; ++current)
+ {
+ cerr << "[" << current->name << "] " << flush;
+ string result = "passed"; // optimistic
+
+ try
+ {
+ allocations::instance().clear();
+ current->action();
+
+ if(!allocations::instance().balanced())
+ {
+ unsigned long allocated = allocations::instance().allocated();
+ unsigned long deallocated = allocations::instance().deallocated();
+#ifdef BOOST_NO_STRINGSTREAM
+ std::ostrstream report;
+#else
+ std::ostringstream report;
+#endif
+ report << "new/delete ("
+ << allocated << " allocated, "
+ << deallocated << " deallocated)"
+ << ends;
+ const string text = report.str();
+#ifdef BOOST_NO_STRINGSTREAM
+ report.freeze(false);
+#endif
+ throw failure(text);
+ }
+
+ ++passed;
+ }
+ catch(const failure & caught)
+ {
+ (result = "failed: ") += caught.what();
+ ++failed;
+ }
+ catch(const not_implemented &)
+ {
+ result = "not implemented";
+ ++unimplemented;
+ }
+ catch(const exception & caught)
+ {
+ (result = "exception: ") += caught.what();
+ ++failed;
+ }
+ catch(...)
+ {
+ result = "failed with unknown exception";
+ ++failed;
+ }
+
+ cerr << result << endl;
+ }
+
+ cerr << (passed + failed) << " tests: "
+ << passed << " passed, "
+ << failed << " failed";
+
+ if(unimplemented)
+ {
+ cerr << " (" << unimplemented << " not implemented)";
+ }
+
+ cerr << endl;
+
+ return failed == 0;
+ }
+}
+
+#endif
+
+// Copyright Kevlin Henney, 2000. All rights reserved.
+//
+// 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)