diff options
author | Tobias Markmann <tm@ayena.de> | 2014-10-19 20:22:58 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2014-10-20 13:49:33 (GMT) |
commit | 6b22dfcf59474dd016a0355a3102a1dd3692d92c (patch) | |
tree | 2b1fd33be433a91e81fee84fdc2bf1b52575d934 /3rdParty/Boost/src/boost/archive/detail/helper_collection.hpp | |
parent | 38b0cb785fea8eae5e48fae56440695fdfd10ee1 (diff) | |
download | swift-6b22dfcf59474dd016a0355a3102a1dd3692d92c.zip swift-6b22dfcf59474dd016a0355a3102a1dd3692d92c.tar.bz2 |
Update Boost in 3rdParty to version 1.56.0.
This updates Boost in our 3rdParty directory to version 1.56.0.
Updated our update.sh script to stop on error.
Changed error reporting in SwiftTools/CrashReporter.cpp to SWIFT_LOG due to
missing include of <iostream> with newer Boost.
Change-Id: I4b35c77de951333979a524097f35f5f83d325edc
Diffstat (limited to '3rdParty/Boost/src/boost/archive/detail/helper_collection.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/archive/detail/helper_collection.hpp | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/archive/detail/helper_collection.hpp b/3rdParty/Boost/src/boost/archive/detail/helper_collection.hpp new file mode 100644 index 0000000..ba3c60c --- /dev/null +++ b/3rdParty/Boost/src/boost/archive/detail/helper_collection.hpp @@ -0,0 +1,111 @@ +#ifndef BOOST_ARCHIVE_DETAIL_HELPER_COLLECTION_HPP +#define BOOST_ARCHIVE_DETAIL_HELPER_COLLECTION_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// helper_collection.hpp: archive support for run-time helpers + +// (C) Copyright 2002-2008 Robert Ramey and Joaquin M Lopez Munoz +// 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) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cstddef> // NULL +#include <typeinfo> +#include <vector> +#include <utility> +#include <memory> +#include <algorithm> + +#include <boost/config.hpp> + +#ifdef BOOST_NO_CXX11_SMART_PTR + #include <boost/smart_ptr/shared_ptr.hpp> + #include <boost/smart_ptr/make_shared.hpp> +#endif + +namespace boost { + +namespace archive { +namespace detail { + +class helper_collection +{ + helper_collection(const helper_collection&); // non-copyable + helper_collection& operator = (const helper_collection&); // non-copyable + + // note: we dont' actually "share" the function object pointer + // we only use shared_ptr to make sure that it get's deleted + + #ifndef BOOST_NO_CXX11_SMART_PTR + typedef std::pair< + const std::type_info *, + std::shared_ptr<void> + > helper_value_type; + template<class T> + std::shared_ptr<void> make_helper_ptr(){ + return std::make_shared<T>(); + } + #else + typedef std::pair< + const std::type_info *, + boost::shared_ptr<void> + > helper_value_type; + template<class T> + boost::shared_ptr<void> make_helper_ptr(){ + return boost::make_shared<T>(); + } + #endif + typedef std::vector<helper_value_type> collection; + collection m_collection; + + struct predicate { + const std::type_info * m_ti; + bool operator()(helper_value_type const &rhs) const { + return *m_ti == *rhs.first; + } + predicate(const std::type_info * ti) : + m_ti(ti) + {} + }; +protected: + helper_collection(){} + ~helper_collection(){} +public: + template<typename Helper> + Helper& get_helper(Helper * = NULL) { + + const std::type_info * eti = & typeid(Helper); + + collection::const_iterator it = + std::find_if( + m_collection.begin(), + m_collection.end(), + predicate(eti) + ); + + void * rval; + if(it == m_collection.end()){ + m_collection.push_back( + std::make_pair(eti, make_helper_ptr<Helper>()) + ); + rval = m_collection.back().second.get(); + } + else{ + rval = it->second.get(); + } + return *static_cast<Helper *>(rval); + } +}; + +} // namespace detail +} // namespace serialization +} // namespace boost + +#endif // BOOST_ARCHIVE_DETAIL_HELPER_COLLECTION_HPP |