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/smart_ptr | |
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/smart_ptr')
55 files changed, 4227 insertions, 1647 deletions
diff --git a/3rdParty/Boost/src/boost/smart_ptr/allocate_shared_array.hpp b/3rdParty/Boost/src/boost/smart_ptr/allocate_shared_array.hpp new file mode 100644 index 0000000..1ae5cc7 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/allocate_shared_array.hpp @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2012-2014 Glen Joseph Fernandes + * glenfe at live dot com + * + * Distributed under the Boost Software License, + * Version 1.0. (See accompanying file LICENSE_1_0.txt + * or copy at http://boost.org/LICENSE_1_0.txt) + */ +#ifndef BOOST_SMART_PTR_ALLOCATE_SHARED_ARRAY_HPP +#define BOOST_SMART_PTR_ALLOCATE_SHARED_ARRAY_HPP + +#include <boost/smart_ptr/detail/array_count_impl.hpp> +#include <boost/smart_ptr/detail/sp_if_array.hpp> + +namespace boost { + template<class T, class A> + inline typename boost::detail::sp_if_array<T>::type + allocate_shared(const A& allocator, std::size_t size) { + typedef typename boost::detail::array_inner<T>::type T1; + typedef typename boost::detail::array_base<T1>::type T2; + typedef boost::detail::ms_init_tag R1; + typedef boost::detail::as_allocator<A, T, R1> A1; + typedef boost::detail::ms_in_allocator_tag D1; + std::size_t n1 = size * boost::detail::array_total<T1>::size; + T1* p1 = 0; + T2* p2 = 0; + D1 d1; + A1 a1(allocator, size, &p2); + shared_ptr<T> s1(p1, d1, a1); + A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter()); + a2->set(0); +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + boost::detail::as_init(allocator, p2, n1); +#else + boost::detail::ms_init(p2, n1); +#endif + a2->set(p2); + p1 = reinterpret_cast<T1*>(p2); + return shared_ptr<T>(s1, p1); + } + + template<class T, class A> + inline typename boost::detail::sp_if_size_array<T>::type + allocate_shared(const A& allocator) { + typedef typename boost::detail::array_inner<T>::type T1; + typedef typename boost::detail::array_base<T1>::type T2; + typedef boost::detail::ms_init_tag R1; + typedef boost::detail::as_allocator<A, T, R1> A1; + typedef boost::detail::ms_in_allocator_tag D1; + enum { + N = boost::detail::array_total<T>::size + }; + T1* p1 = 0; + T2* p2 = 0; + D1 d1; + A1 a1(allocator, &p2); + shared_ptr<T> s1(p1, d1, a1); + A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter()); + a2->set(0); +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + boost::detail::as_init(allocator, p2, N); +#else + boost::detail::ms_init(p2, N); +#endif + a2->set(p2); + p1 = reinterpret_cast<T1*>(p2); + return shared_ptr<T>(s1, p1); + } + + template<class T, class A> + inline typename boost::detail::sp_if_array<T>::type + allocate_shared(const A& allocator, std::size_t size, + const typename boost::detail::array_inner<T>::type& value) { + typedef typename boost::detail::array_inner<T>::type T1; + typedef typename boost::detail::array_base<T1>::type T2; + typedef const T2 T3; + typedef boost::detail::ms_init_tag R1; + typedef boost::detail::as_allocator<A, T, R1> A1; + typedef boost::detail::ms_in_allocator_tag D1; + enum { + M = boost::detail::array_total<T1>::size + }; + std::size_t n1 = M * size; + T1* p1 = 0; + T2* p2 = 0; + T3* p3 = reinterpret_cast<T3*>(&value); + D1 d1; + A1 a1(allocator, size, &p2); + shared_ptr<T> s1(p1, d1, a1); + A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter()); + a2->set(0); +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + boost::detail::as_init<T2, A, M>(allocator, p2, n1, p3); +#else + boost::detail::ms_init<T2, M>(p2, n1, p3); +#endif + a2->set(p2); + p1 = reinterpret_cast<T1*>(p2); + return shared_ptr<T>(s1, p1); + } + + template<class T, class A> + inline typename boost::detail::sp_if_size_array<T>::type + allocate_shared(const A& allocator, + const typename boost::detail::array_inner<T>::type& value) { + typedef typename boost::detail::array_inner<T>::type T1; + typedef typename boost::detail::array_base<T1>::type T2; + typedef const T2 T3; + typedef boost::detail::ms_init_tag R1; + typedef boost::detail::as_allocator<A, T, R1> A1; + typedef boost::detail::ms_in_allocator_tag D1; + enum { + N = boost::detail::array_total<T>::size, + M = boost::detail::array_total<T1>::size + }; + T1* p1 = 0; + T2* p2 = 0; + T3* p3 = reinterpret_cast<T3*>(&value); + D1 d1; + A1 a1(allocator, &p2); + shared_ptr<T> s1(p1, d1, a1); + A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter()); + a2->set(0); +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + boost::detail::as_init<T2, A, M>(allocator, p2, N, p3); +#else + boost::detail::ms_init<T2, M>(p2, N, p3); +#endif + a2->set(p2); + p1 = reinterpret_cast<T1*>(p2); + return shared_ptr<T>(s1, p1); + } + + template<class T, class A> + inline typename boost::detail::sp_if_array<T>::type + allocate_shared_noinit(const A& allocator, std::size_t size) { + typedef typename boost::detail::array_inner<T>::type T1; + typedef typename boost::detail::array_base<T1>::type T2; + typedef boost::detail::ms_noinit_tag R1; + typedef boost::detail::as_allocator<A, T, R1> A1; + typedef boost::detail::ms_in_allocator_tag D1; + std::size_t n1 = size * boost::detail::array_total<T1>::size; + T1* p1 = 0; + T2* p2 = 0; + D1 d1; + A1 a1(allocator, size, &p2); + shared_ptr<T> s1(p1, d1, a1); + A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter()); + a2->set(0); + boost::detail::ms_noinit(p2, n1); + a2->set(p2); + p1 = reinterpret_cast<T1*>(p2); + return shared_ptr<T>(s1, p1); + } + + template<class T, class A> + inline typename boost::detail::sp_if_size_array<T>::type + allocate_shared_noinit(const A& allocator) { + typedef typename boost::detail::array_inner<T>::type T1; + typedef typename boost::detail::array_base<T1>::type T2; + typedef boost::detail::ms_noinit_tag R1; + typedef boost::detail::as_allocator<A, T, R1> A1; + typedef boost::detail::ms_in_allocator_tag D1; + enum { + N = boost::detail::array_total<T>::size + }; + T1* p1 = 0; + T2* p2 = 0; + D1 d1; + A1 a1(allocator, &p2); + shared_ptr<T> s1(p1, d1, a1); + A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter()); + a2->set(0); + boost::detail::ms_noinit(p2, N); + a2->set(p2); + p1 = reinterpret_cast<T1*>(p2); + return shared_ptr<T>(s1, p1); + } +} + +#endif diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/array_allocator.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/array_allocator.hpp new file mode 100644 index 0000000..4f9dc2b --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/array_allocator.hpp @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2012-2014 Glen Joseph Fernandes + * glenfe at live dot com + * + * Distributed under the Boost Software License, + * Version 1.0. (See accompanying file LICENSE_1_0.txt + * or copy at http://boost.org/LICENSE_1_0.txt) + */ +#ifndef BOOST_SMART_PTR_DETAIL_ARRAY_ALLOCATOR_HPP +#define BOOST_SMART_PTR_DETAIL_ARRAY_ALLOCATOR_HPP + +#include <boost/align/align.hpp> +#include <boost/smart_ptr/detail/array_traits.hpp> +#include <boost/smart_ptr/detail/array_utility.hpp> +#include <boost/type_traits/alignment_of.hpp> + +namespace boost { + namespace detail { + struct ms_init_tag { }; + struct ms_noinit_tag { }; + + template<class T> + struct ms_allocator_state; + + template<class T> + struct ms_allocator_state<T[]> { + typedef typename array_base<T>::type type; + + ms_allocator_state(std::size_t size_, + type** result_) + : size(size_ * array_total<T>::size), + result(result_) { + } + + std::size_t size; + + union { + type** result; + type* object; + }; + }; + + template<class T, std::size_t N> + struct ms_allocator_state<T[N]> { + typedef typename array_base<T>::type type; + + ms_allocator_state(type** result_) + : result(result_) { + } + + enum { + size = array_total<T[N]>::size + }; + + union { + type** result; + type* object; + }; + }; + + template<class A, class T, class R> + class as_allocator + : public A { + template<class A_, class T_, class R_> + friend class as_allocator; + +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + typedef std::allocator_traits<A> AT; + typedef typename AT::template rebind_alloc<char> CA; + typedef typename AT::template rebind_traits<char> CT; +#else + typedef typename A::template rebind<char>::other CA; +#endif + + public: + typedef A allocator_type; + +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + typedef typename AT::value_type value_type; + typedef typename AT::pointer pointer; + typedef typename AT::const_pointer const_pointer; + typedef typename AT::void_pointer void_pointer; + typedef typename AT::const_void_pointer const_void_pointer; + typedef typename AT::size_type size_type; + typedef typename AT::difference_type difference_type; +#else + typedef typename A::value_type value_type; + typedef typename A::pointer pointer; + typedef typename A::const_pointer const_pointer; + typedef typename A::size_type size_type; + typedef typename A::difference_type difference_type; + typedef typename A::reference reference; + typedef typename A::const_reference const_reference; + typedef void* void_pointer; + typedef const void* const_void_pointer; +#endif + + template<class U> + struct rebind { +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + typedef as_allocator<typename AT:: + template rebind_alloc<U>, T, R> other; +#else + typedef as_allocator<typename A:: + template rebind<U>::other, T, R> other; +#endif + }; + + typedef typename array_base<T>::type type; + + as_allocator(const A& allocator_, type** result) + : A(allocator_), + data(result) { + } + + as_allocator(const A& allocator_, std::size_t size, + type** result) + : A(allocator_), + data(size, result) { + } + + template<class U> + as_allocator(const as_allocator<U, T, R>& other) + : A(other.allocator()), + data(other.data) { + } + + pointer allocate(size_type count, const_void_pointer = 0) { + enum { + M = boost::alignment_of<type>::value + }; + std::size_t n1 = count * sizeof(value_type); + std::size_t n2 = data.size * sizeof(type); + std::size_t n3 = n2 + M; + CA ca(allocator()); + void* p1 = ca.allocate(n1 + n3); + void* p2 = static_cast<char*>(p1) + n1; + (void)boost::alignment::align(M, n2, p2, n3); + *data.result = static_cast<type*>(p2); + return static_cast<value_type*>(p1); + } + + void deallocate(pointer memory, size_type count) { + enum { + M = boost::alignment_of<type>::value + }; + std::size_t n1 = count * sizeof(value_type); + std::size_t n2 = data.size * sizeof(type) + M; + char* p1 = reinterpret_cast<char*>(memory); + CA ca(allocator()); + ca.deallocate(p1, n1 + n2); + } + + const A& allocator() const { + return static_cast<const A&>(*this); + } + + A& allocator() { + return static_cast<A&>(*this); + } + + void set(type* memory) { + data.object = memory; + } + + void operator()() { + if (data.object) { + R tag; + release(tag); + } + } + + private: + void release(ms_init_tag) { +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + as_destroy(allocator(), data.object, data.size); +#else + ms_destroy(data.object, data.size); +#endif + } + + void release(ms_noinit_tag) { + ms_destroy(data.object, data.size); + } + + ms_allocator_state<T> data; + }; + + template<class A1, class A2, class T, class R> + bool operator==(const as_allocator<A1, T, R>& a1, + const as_allocator<A2, T, R>& a2) { + return a1.allocator() == a2.allocator(); + } + + template<class A1, class A2, class T, class R> + bool operator!=(const as_allocator<A1, T, R>& a1, + const as_allocator<A2, T, R>& a2) { + return a1.allocator() != a2.allocator(); + } + + template<class T, class Y = char> + class ms_allocator; + + template<class T, class Y> + class ms_allocator { + template<class T_, class Y_> + friend class ms_allocator; + + public: + typedef typename array_base<T>::type type; + + typedef Y value_type; + typedef Y* pointer; + typedef const Y* const_pointer; + typedef std::size_t size_type; + typedef ptrdiff_t difference_type; + typedef Y& reference; + typedef const Y& const_reference; + + template<class U> + struct rebind { + typedef ms_allocator<T, U> other; + }; + + ms_allocator(type** result) + : data(result) { + } + + ms_allocator(std::size_t size, type** result) + : data(size, result) { + } + + template<class U> + ms_allocator(const ms_allocator<T, U>& other) + : data(other.data) { + } + + pointer allocate(size_type count, const void* = 0) { + enum { + M = boost::alignment_of<type>::value + }; + std::size_t n1 = count * sizeof(Y); + std::size_t n2 = data.size * sizeof(type); + std::size_t n3 = n2 + M; + void* p1 = ::operator new(n1 + n3); + void* p2 = static_cast<char*>(p1) + n1; + (void)boost::alignment::align(M, n2, p2, n3); + *data.result = static_cast<type*>(p2); + return static_cast<Y*>(p1); + } + + void deallocate(pointer memory, size_type) { + void* p1 = memory; + ::operator delete(p1); + } + +#if defined(BOOST_NO_CXX11_ALLOCATOR) + pointer address(reference value) const { + return &value; + } + + const_pointer address(const_reference value) const { + return &value; + } + + size_type max_size() const { + enum { + N = static_cast<std::size_t>(-1) / sizeof(Y) + }; + return N; + } + + void construct(pointer memory, const_reference value) { + void* p1 = memory; + ::new(p1) Y(value); + } + + void destroy(pointer memory) { + (void)memory; + memory->~Y(); + } +#endif + + void set(type* memory) { + data.object = memory; + } + + void operator()() { + if (data.object) { + ms_destroy(data.object, data.size); + } + } + + private: + ms_allocator_state<T> data; + }; + + template<class T, class Y1, class Y2> + bool operator==(const ms_allocator<T, Y1>&, + const ms_allocator<T, Y2>&) { + return true; + } + + template<class T, class Y1, class Y2> + bool operator!=(const ms_allocator<T, Y1>&, + const ms_allocator<T, Y2>&) { + return false; + } + + class ms_in_allocator_tag { + public: + void operator()(const void*) { + } + }; + } +} + +#endif diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/array_count_impl.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/array_count_impl.hpp new file mode 100644 index 0000000..b7c9617 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/array_count_impl.hpp @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014 Glen Joseph Fernandes + * glenfe at live dot com + * + * Distributed under the Boost Software License, + * Version 1.0. (See accompanying file LICENSE_1_0.txt + * or copy at http://boost.org/LICENSE_1_0.txt) + */ +#ifndef BOOST_SMART_PTR_DETAIL_ARRAY_COUNT_IMPL_HPP +#define BOOST_SMART_PTR_DETAIL_ARRAY_COUNT_IMPL_HPP + +#include <boost/smart_ptr/detail/array_allocator.hpp> +#include <boost/smart_ptr/detail/sp_counted_impl.hpp> + +namespace boost { + namespace detail { + template<class P, class A> + class sp_counted_impl_pda<P, ms_in_allocator_tag, A> + : public sp_counted_base { + typedef ms_in_allocator_tag D; + typedef sp_counted_impl_pda<P, D, A> Y; + public: + sp_counted_impl_pda(P, D, const A& allocator_) + : allocator(allocator_) { + } + + virtual void dispose() { + allocator(); + } + + virtual void destroy() { +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + typedef typename std::allocator_traits<A>:: + template rebind_alloc<Y> YA; + typedef typename std::allocator_traits<A>:: + template rebind_traits<Y> YT; +#else + typedef typename A::template rebind<Y>::other YA; +#endif + YA a1(allocator); +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + YT::destroy(a1, this); + YT::deallocate(a1, this, 1); +#else + this->~Y(); + a1.deallocate(this, 1); +#endif + } + + virtual void* get_deleter(const sp_typeinfo&) { + return &reinterpret_cast<char&>(allocator); + } + + virtual void* get_untyped_deleter() { + return &reinterpret_cast<char&>(allocator); + } + + private: + sp_counted_impl_pda(const sp_counted_impl_pda&); + sp_counted_impl_pda& operator=(const sp_counted_impl_pda&); + + A allocator; + }; + } +} + +#endif diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/array_traits.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/array_traits.hpp new file mode 100644 index 0000000..819c5ba --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/array_traits.hpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2012-2014 Glen Joseph Fernandes + * glenfe at live dot com + * + * Distributed under the Boost Software License, + * Version 1.0. (See accompanying file LICENSE_1_0.txt + * or copy at http://boost.org/LICENSE_1_0.txt) + */ +#ifndef BOOST_SMART_PTR_DETAIL_ARRAY_TRAITS_HPP +#define BOOST_SMART_PTR_DETAIL_ARRAY_TRAITS_HPP + +#include <boost/type_traits/remove_cv.hpp> + +namespace boost { + namespace detail { + template<class T> + struct array_base { + typedef typename boost::remove_cv<T>::type type; + }; + + template<class T> + struct array_base<T[]> { + typedef typename array_base<T>::type type; + }; + + template<class T, std::size_t N> + struct array_base<T[N]> { + typedef typename array_base<T>::type type; + }; + + template<class T> + struct array_total { + enum { + size = 1 + }; + }; + + template<class T, std::size_t N> + struct array_total<T[N]> { + enum { + size = N * array_total<T>::size + }; + }; + + template<class T> + struct array_inner; + + template<class T> + struct array_inner<T[]> { + typedef T type; + }; + + template<class T, std::size_t N> + struct array_inner<T[N]> { + typedef T type; + }; + } +} + +#endif diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/array_utility.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/array_utility.hpp new file mode 100644 index 0000000..84029a1 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/array_utility.hpp @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2012-2014 Glen Joseph Fernandes + * glenfe at live dot com + * + * Distributed under the Boost Software License, + * Version 1.0. (See accompanying file LICENSE_1_0.txt + * or copy at http://boost.org/LICENSE_1_0.txt) + */ +#ifndef BOOST_SMART_PTR_DETAIL_ARRAY_UTILITY_HPP +#define BOOST_SMART_PTR_DETAIL_ARRAY_UTILITY_HPP + +#include <boost/config.hpp> +#include <boost/type_traits/has_trivial_constructor.hpp> +#include <boost/type_traits/has_trivial_destructor.hpp> +#if !defined(BOOST_NO_CXX11_ALLOCATOR) +#include <memory> +#endif + +namespace boost { + namespace detail { + typedef boost::true_type ms_is_trivial; + typedef boost::false_type ms_no_trivial; + + template<class T> + inline void ms_destroy(T*, std::size_t, ms_is_trivial) { + } + + template<class T> + inline void ms_destroy(T* memory, std::size_t size, ms_no_trivial) { + for (std::size_t i = size; i > 0;) { + memory[--i].~T(); + } + } + + template<class T> + inline void ms_destroy(T* memory, std::size_t size) { + boost::has_trivial_destructor<T> trivial; + ms_destroy(memory, size, trivial); + } + + template<class T> + inline void ms_init(T* memory, std::size_t size, ms_is_trivial) { + for (std::size_t i = 0; i < size; i++) { + void* p1 = memory + i; + ::new(p1) T(); + } + } + + template<class T> + inline void ms_init(T* memory, std::size_t size, ms_no_trivial) { +#if !defined(BOOST_NO_EXCEPTIONS) + std::size_t i = 0; + try { + for (; i < size; i++) { + void* p1 = memory + i; + ::new(p1) T(); + } + } catch (...) { + ms_destroy(memory, i); + throw; + } +#else + for (std::size_t i = 0; i < size; i++) { + void* p1 = memory + i; + ::new(p1) T(); + } +#endif + } + + template<class T> + inline void ms_init(T* memory, std::size_t size) { + boost::has_trivial_default_constructor<T> trivial; + ms_init(memory, size, trivial); + } + + template<class T, std::size_t N> + inline void ms_init(T* memory, std::size_t size, const T* list) { +#if !defined(BOOST_NO_EXCEPTIONS) + std::size_t i = 0; + try { + for (; i < size; i++) { + void* p1 = memory + i; + ::new(p1) T(list[i % N]); + } + } catch (...) { + ms_destroy(memory, i); + throw; + } +#else + for (std::size_t i = 0; i < size; i++) { + void* p1 = memory + i; + ::new(p1) T(list[i % N]); + } +#endif + } + +#if !defined(BOOST_NO_CXX11_ALLOCATOR) + template<class T, class A> + inline void as_destroy(const A& allocator, T* memory, + std::size_t size) { + typedef typename std::allocator_traits<A>:: + template rebind_alloc<T> TA; + typedef typename std::allocator_traits<A>:: + template rebind_traits<T> TT; + TA a2(allocator); + for (std::size_t i = size; i > 0;) { + TT::destroy(a2, &memory[--i]); + } + } + + template<class T, class A> + inline void as_init(const A& allocator, T* memory, std::size_t size, + ms_is_trivial) { + typedef typename std::allocator_traits<A>:: + template rebind_alloc<T> TA; + typedef typename std::allocator_traits<A>:: + template rebind_traits<T> TT; + TA a2(allocator); + for (std::size_t i = 0; i < size; i++) { + TT::construct(a2, memory + i); + } + } + + template<class T, class A> + inline void as_init(const A& allocator, T* memory, std::size_t size, + ms_no_trivial) { + typedef typename std::allocator_traits<A>:: + template rebind_alloc<T> TA; + typedef typename std::allocator_traits<A>:: + template rebind_traits<T> TT; + TA a2(allocator); +#if !defined(BOOST_NO_EXCEPTIONS) + std::size_t i = 0; + try { + for (; i < size; i++) { + TT::construct(a2, memory + i); + } + } catch (...) { + as_destroy(a2, memory, i); + throw; + } +#else + for (std::size_t i = 0; i < size; i++) { + TT::construct(a2, memory + i); + } +#endif + } + + template<class T, class A> + inline void as_init(const A& allocator, T* memory, std::size_t size) { + boost::has_trivial_default_constructor<T> trivial; + as_init(allocator, memory, size, trivial); + } + + template<class T, class A, std::size_t N> + inline void as_init(const A& allocator, T* memory, std::size_t size, + const T* list) { + typedef typename std::allocator_traits<A>:: + template rebind_alloc<T> TA; + typedef typename std::allocator_traits<A>:: + template rebind_traits<T> TT; + TA a2(allocator); +#if !defined(BOOST_NO_EXCEPTIONS) + std::size_t i = 0; + try { + for (; i < size; i++) { + TT::construct(a2, memory + i, list[i % N]); + } + } catch (...) { + as_destroy(a2, memory, i); + throw; + } +#else + for (std::size_t i = 0; i < size; i++) { + TT::construct(a2, memory + i, list[i % N]); + } +#endif + } +#endif + + template<class T> + inline void ms_noinit(T*, std::size_t, ms_is_trivial) { + } + + template<class T> + inline void ms_noinit(T* memory, std::size_t size, ms_no_trivial) { +#if !defined(BOOST_NO_EXCEPTIONS) + std::size_t i = 0; + try { + for (; i < size; i++) { + void* p1 = memory + i; + ::new(p1) T; + } + } catch (...) { + ms_destroy(memory, i); + throw; + } +#else + for (std::size_t i = 0; i < size; i++) { + void* p1 = memory + i; + ::new(p1) T; + } +#endif + } + + template<class T> + inline void ms_noinit(T* memory, std::size_t size) { + boost::has_trivial_default_constructor<T> trivial; + ms_noinit(memory, size, trivial); + } + } +} + +#endif diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count.hpp index cc44ac2..8aefd44 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count.hpp @@ -11,10 +11,11 @@ // boost/detail/atomic_count.hpp - thread/SMP safe reference counter // // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. +// Copyright (c) 2013 Peter Dimov // -// 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) +// 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 // // typedef <implementation-defined> boost::detail::atomic_count; // @@ -27,92 +28,68 @@ // a; // // Returns: (long) the current value of a +// Memory Ordering: acquire // // ++a; // // Effects: Atomically increments the value of a // Returns: (long) the new value of a +// Memory Ordering: acquire/release // // --a; // // Effects: Atomically decrements the value of a // Returns: (long) the new value of a -// -// Important note: when --a returns zero, it must act as a -// read memory barrier (RMB); i.e. the calling thread must -// have a synchronized view of the memory -// -// On Intel IA-32 (x86) memory is always synchronized, so this -// is not a problem. -// -// On many architectures the atomic instructions already act as -// a memory barrier. -// -// This property is necessary for proper reference counting, since -// a thread can update the contents of a shared object, then -// release its reference, and another thread may immediately -// release the last reference causing object destruction. -// -// The destructor needs to have a synchronized view of the -// object to perform proper cleanup. -// -// Original example by Alexander Terekhov: -// -// Given: -// -// - a mutable shared object OBJ; -// - two threads THREAD1 and THREAD2 each holding -// a private smart_ptr object pointing to that OBJ. -// -// t1: THREAD1 updates OBJ (thread-safe via some synchronization) -// and a few cycles later (after "unlock") destroys smart_ptr; -// -// t2: THREAD2 destroys smart_ptr WITHOUT doing any synchronization -// with respect to shared mutable object OBJ; OBJ destructors -// are called driven by smart_ptr interface... +// Memory Ordering: acquire/release // #include <boost/config.hpp> #include <boost/smart_ptr/detail/sp_has_sync.hpp> -#ifndef BOOST_HAS_THREADS +#if defined( BOOST_AC_DISABLE_THREADS ) +# include <boost/smart_ptr/detail/atomic_count_nt.hpp> -namespace boost -{ +#elif defined( BOOST_AC_USE_STD_ATOMIC ) +# include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp> -namespace detail -{ +#elif defined( BOOST_AC_USE_SPINLOCK ) +# include <boost/smart_ptr/detail/atomic_count_spin.hpp> -typedef long atomic_count; +#elif defined( BOOST_AC_USE_PTHREADS ) +# include <boost/smart_ptr/detail/atomic_count_pt.hpp> -} +#elif defined( BOOST_SP_DISABLE_THREADS ) +# include <boost/smart_ptr/detail/atomic_count_nt.hpp> -} +#elif defined( BOOST_SP_USE_STD_ATOMIC ) +# include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp> -#elif defined(BOOST_AC_USE_PTHREADS) -# include <boost/smart_ptr/detail/atomic_count_pthreads.hpp> +#elif defined( BOOST_SP_USE_SPINLOCK ) +# include <boost/smart_ptr/detail/atomic_count_spin.hpp> -#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) -# include <boost/smart_ptr/detail/atomic_count_gcc_x86.hpp> +#elif defined( BOOST_SP_USE_PTHREADS ) +# include <boost/smart_ptr/detail/atomic_count_pt.hpp> -#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# include <boost/smart_ptr/detail/atomic_count_win32.hpp> +#elif defined( BOOST_DISABLE_THREADS ) && !defined( BOOST_SP_ENABLE_THREADS ) && !defined( BOOST_DISABLE_WIN32 ) +# include <boost/smart_ptr/detail/atomic_count_nt.hpp> + +#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) && !defined( __PATHSCALE__ ) +# include <boost/smart_ptr/detail/atomic_count_gcc_x86.hpp> #elif defined( BOOST_SP_HAS_SYNC ) -# include <boost/smart_ptr/detail/atomic_count_sync.hpp> +# include <boost/smart_ptr/detail/atomic_count_sync.hpp> -#elif defined(__GLIBCPP__) || defined(__GLIBCXX__) -# include <boost/smart_ptr/detail/atomic_count_gcc.hpp> +#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# include <boost/smart_ptr/detail/atomic_count_win32.hpp> -#elif defined(BOOST_HAS_PTHREADS) +#elif defined(__GLIBCPP__) || defined(__GLIBCXX__) +# include <boost/smart_ptr/detail/atomic_count_gcc.hpp> -# define BOOST_AC_USE_PTHREADS -# include <boost/smart_ptr/detail/atomic_count_pthreads.hpp> +#elif !defined( BOOST_HAS_THREADS ) +# include <boost/smart_ptr/detail/atomic_count_nt.hpp> #else - -// Use #define BOOST_DISABLE_THREADS to avoid the error -#error Unrecognized threading platform +# include <boost/smart_ptr/detail/atomic_count_spin.hpp> #endif diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_nt.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_nt.hpp new file mode 100644 index 0000000..3bbf138 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_nt.hpp @@ -0,0 +1,59 @@ +#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_NT_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_NT_HPP_INCLUDED + +// +// boost/detail/atomic_count_nt.hpp +// +// Trivial atomic_count for the single-threaded case +// +// http://gcc.gnu.org/onlinedocs/porting/Thread-safety.html +// +// Copyright 2013 Peter Dimov +// +// 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 +// + +namespace boost +{ + +namespace detail +{ + +class atomic_count +{ +public: + + explicit atomic_count( long v ): value_( v ) + { + } + + long operator++() + { + return ++value_; + } + + long operator--() + { + return --value_; + } + + operator long() const + { + return value_; + } + +private: + + atomic_count(atomic_count const &); + atomic_count & operator=(atomic_count const &); + + long value_; +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_NT_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_pthreads.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_pt.hpp index 05f7867..f99b910 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_pthreads.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_pt.hpp @@ -11,6 +11,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // +#include <boost/assert.hpp> #include <pthread.h> // @@ -37,12 +38,12 @@ private: scoped_lock(pthread_mutex_t & m): m_(m) { - pthread_mutex_lock(&m_); + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); } ~scoped_lock() { - pthread_mutex_unlock(&m_); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); } private: @@ -54,12 +55,12 @@ public: explicit atomic_count(long v): value_(v) { - pthread_mutex_init(&mutex_, 0); + BOOST_VERIFY( pthread_mutex_init( &mutex_, 0 ) == 0 ); } ~atomic_count() { - pthread_mutex_destroy(&mutex_); + BOOST_VERIFY( pthread_mutex_destroy( &mutex_ ) == 0 ); } long operator++() diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_spin.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_spin.hpp new file mode 100644 index 0000000..8e62349 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_spin.hpp @@ -0,0 +1,62 @@ +#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SPIN_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SPIN_HPP_INCLUDED + +// +// boost/detail/atomic_count_spin.hpp +// +// Copyright (c) 2013 Peter Dimov +// +// 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/smart_ptr/detail/spinlock_pool.hpp> + +namespace boost +{ + +namespace detail +{ + +class atomic_count +{ +private: + +public: + + explicit atomic_count( long v ): value_( v ) + { + } + + long operator++() + { + spinlock_pool<0>::scoped_lock lock( &value_ ); + return ++value_; + } + + long operator--() + { + spinlock_pool<0>::scoped_lock lock( &value_ ); + return --value_; + } + + operator long() const + { + spinlock_pool<0>::scoped_lock lock( &value_ ); + return value_; + } + +private: + + atomic_count(atomic_count const &); + atomic_count & operator=(atomic_count const &); + + long value_; +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SPIN_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_std_atomic.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_std_atomic.hpp new file mode 100644 index 0000000..55b9998 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_std_atomic.hpp @@ -0,0 +1,60 @@ +#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_STD_ATOMIC_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_STD_ATOMIC_HPP_INCLUDED + +// +// boost/detail/atomic_count_std_atomic.hpp +// +// atomic_count for std::atomic +// +// Copyright 2013 Peter Dimov +// +// 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 <atomic> +#include <cstdint> + +namespace boost +{ + +namespace detail +{ + +class atomic_count +{ +public: + + explicit atomic_count( long v ): value_( v ) + { + } + + long operator++() + { + return value_.fetch_add( 1, std::memory_order_acq_rel ) + 1; + } + + long operator--() + { + return value_.fetch_sub( 1, std::memory_order_acq_rel ) - 1; + } + + operator long() const + { + return value_.load( std::memory_order_acquire ); + } + +private: + + atomic_count(atomic_count const &); + atomic_count & operator=(atomic_count const &); + + std::atomic_int_least32_t value_; +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_STD_ATOMIC_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_win32.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_win32.hpp index 60a0569..633e73c 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_win32.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/atomic_count_win32.hpp @@ -17,7 +17,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // -#include <boost/detail/interlocked.hpp> +#include <boost/smart_ptr/detail/sp_interlocked.hpp> namespace boost { @@ -35,12 +35,12 @@ public: long operator++() { - return BOOST_INTERLOCKED_INCREMENT( &value_ ); + return BOOST_SP_INTERLOCKED_INCREMENT( &value_ ); } long operator--() { - return BOOST_INTERLOCKED_DECREMENT( &value_ ); + return BOOST_SP_INTERLOCKED_DECREMENT( &value_ ); } operator long() const diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/lwm_win32_cs.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/lwm_win32_cs.hpp index 00477e4..a93cf09 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/lwm_win32_cs.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/lwm_win32_cs.hpp @@ -11,12 +11,15 @@ // boost/detail/lwm_win32_cs.hpp // // Copyright (c) 2002, 2003 Peter Dimov +// Copyright (c) Microsoft Corporation 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 <boost/predef.h> + #ifdef BOOST_USE_WINDOWS_H # include <windows.h> #endif @@ -43,7 +46,11 @@ struct critical_section #endif }; +#if BOOST_PLAT_WINDOWS_RUNTIME +extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSectionEx(critical_section *, unsigned long, unsigned long); +#else extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(critical_section *); +#endif extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(critical_section *); extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(critical_section *); extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(critical_section *); @@ -67,7 +74,11 @@ public: lightweight_mutex() { +#if BOOST_PLAT_WINDOWS_RUNTIME + InitializeCriticalSectionEx(&cs_, 4000, 0); +#else InitializeCriticalSection(&cs_); +#endif } ~lightweight_mutex() diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/operator_bool.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/operator_bool.hpp index 842a05d..8ae1527 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/operator_bool.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/operator_bool.hpp @@ -1,14 +1,21 @@ // This header intentionally has no include guards. // -// Copyright (c) 2001-2009 Peter Dimov +// Copyright (c) 2001-2009, 2012 Peter Dimov // // 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 -#if ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__) +#if !defined( BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS ) && !defined( BOOST_NO_CXX11_NULLPTR ) - operator bool () const + explicit operator bool () const BOOST_NOEXCEPT + { + return px != 0; + } + +#elif ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__) + + operator bool () const BOOST_NOEXCEPT { return px != 0; } @@ -21,7 +28,7 @@ typedef void (*unspecified_bool_type)( this_type*** ); - operator unspecified_bool_type() const // never throws + operator unspecified_bool_type() const BOOST_NOEXCEPT { return px == 0? 0: unspecified_bool; } @@ -31,18 +38,18 @@ ( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) ) || \ ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) ) - typedef T * (this_type::*unspecified_bool_type)() const; + typedef element_type * (this_type::*unspecified_bool_type)() const; - operator unspecified_bool_type() const // never throws + operator unspecified_bool_type() const BOOST_NOEXCEPT { return px == 0? 0: &this_type::get; } #else - typedef T * this_type::*unspecified_bool_type; + typedef element_type * this_type::*unspecified_bool_type; - operator unspecified_bool_type() const // never throws + operator unspecified_bool_type() const BOOST_NOEXCEPT { return px == 0? 0: &this_type::px; } @@ -50,7 +57,7 @@ #endif // operator! is redundant, but some compilers need it - bool operator! () const // never throws + bool operator! () const BOOST_NOEXCEPT { return px == 0; } diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/shared_array_nmt.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/shared_array_nmt.hpp deleted file mode 100644 index 450c9bc..0000000 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/shared_array_nmt.hpp +++ /dev/null @@ -1,151 +0,0 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SHARED_ARRAY_NMT_HPP_INCLUDED -#define BOOST_SMART_PTR_DETAIL_SHARED_ARRAY_NMT_HPP_INCLUDED - -// -// detail/shared_array_nmt.hpp - shared_array.hpp without member templates -// -// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. -// Copyright (c) 2001, 2002 Peter Dimov -// -// 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/smart_ptr/shared_array.htm for documentation. -// - -#include <boost/assert.hpp> -#include <boost/checked_delete.hpp> -#include <boost/throw_exception.hpp> -#include <boost/smart_ptr/detail/atomic_count.hpp> - -#include <cstddef> // for std::ptrdiff_t -#include <algorithm> // for std::swap -#include <functional> // for std::less -#include <new> // for std::bad_alloc - -namespace boost -{ - -template<class T> class shared_array -{ -private: - - typedef detail::atomic_count count_type; - -public: - - typedef T element_type; - - explicit shared_array(T * p = 0): px(p) - { -#ifndef BOOST_NO_EXCEPTIONS - - try // prevent leak if new throws - { - pn = new count_type(1); - } - catch(...) - { - boost::checked_array_delete(p); - throw; - } - -#else - - pn = new count_type(1); - - if(pn == 0) - { - boost::checked_array_delete(p); - boost::throw_exception(std::bad_alloc()); - } - -#endif - } - - ~shared_array() - { - if(--*pn == 0) - { - boost::checked_array_delete(px); - delete pn; - } - } - - shared_array(shared_array const & r) : px(r.px) // never throws - { - pn = r.pn; - ++*pn; - } - - shared_array & operator=(shared_array const & r) - { - shared_array(r).swap(*this); - return *this; - } - - void reset(T * p = 0) - { - BOOST_ASSERT(p == 0 || p != px); - shared_array(p).swap(*this); - } - - T * get() const // never throws - { - return px; - } - - T & operator[](std::ptrdiff_t i) const // never throws - { - BOOST_ASSERT(px != 0); - BOOST_ASSERT(i >= 0); - return px[i]; - } - - long use_count() const // never throws - { - return *pn; - } - - bool unique() const // never throws - { - return *pn == 1; - } - - void swap(shared_array<T> & other) // never throws - { - std::swap(px, other.px); - std::swap(pn, other.pn); - } - -private: - - T * px; // contained pointer - count_type * pn; // ptr to reference counter - -}; // shared_array - -template<class T, class U> inline bool operator==(shared_array<T> const & a, shared_array<U> const & b) -{ - return a.get() == b.get(); -} - -template<class T, class U> inline bool operator!=(shared_array<T> const & a, shared_array<U> const & b) -{ - return a.get() != b.get(); -} - -template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) -{ - return std::less<T*>()(a.get(), b.get()); -} - -template<class T> void swap(shared_array<T> & a, shared_array<T> & b) -{ - a.swap(b); -} - -} // namespace boost - -#endif // #ifndef BOOST_SMART_PTR_DETAIL_SHARED_ARRAY_NMT_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/shared_count.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/shared_count.hpp index f96a220..1e7d688 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/shared_count.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/shared_count.hpp @@ -35,7 +35,14 @@ // rather than including <memory> directly: #include <boost/config/no_tr1/memory.hpp> // std::auto_ptr #include <functional> // std::less -#include <new> // std::bad_alloc + +#ifdef BOOST_NO_EXCEPTIONS +# include <new> // std::bad_alloc +#endif + +#if !defined( BOOST_NO_CXX11_SMART_PTR ) +# include <boost/utility/addressof.hpp> +#endif namespace boost { @@ -56,6 +63,38 @@ template< class D > struct sp_inplace_tag { }; +#if !defined( BOOST_NO_CXX11_SMART_PTR ) + +template< class T > class sp_reference_wrapper +{ +public: + + explicit sp_reference_wrapper( T & t): t_( boost::addressof( t ) ) + { + } + + template< class Y > void operator()( Y * p ) const + { + (*t_)( p ); + } + +private: + + T * t_; +}; + +template< class D > struct sp_convert_reference +{ + typedef D type; +}; + +template< class D > struct sp_convert_reference< D& > +{ + typedef sp_reference_wrapper< D > type; +}; + +#endif + class weak_count; class shared_count @@ -161,7 +200,7 @@ public: } catch( ... ) { - D()( p ); // delete p + D::operator_fn( p ); // delete p throw; } @@ -171,7 +210,7 @@ public: if( pi_ == 0 ) { - D()( p ); // delete p + D::operator_fn( p ); // delete p boost::throw_exception( std::bad_alloc() ); } @@ -186,16 +225,35 @@ public: #endif { typedef sp_counted_impl_pda<P, D, A> impl_type; + +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + typedef typename std::allocator_traits<A>::template rebind_alloc< impl_type > A2; + +#else + typedef typename A::template rebind< impl_type >::other A2; +#endif + A2 a2( a ); #ifndef BOOST_NO_EXCEPTIONS try { +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + impl_type * pi = std::allocator_traits<A2>::allocate( a2, 1 ); + pi_ = pi; + std::allocator_traits<A2>::construct( a2, pi, p, d, a ); + +#else + pi_ = a2.allocate( 1, static_cast< impl_type* >( 0 ) ); - new( static_cast< void* >( pi_ ) ) impl_type( p, d, a ); + ::new( static_cast< void* >( pi_ ) ) impl_type( p, d, a ); + +#endif } catch(...) { @@ -211,11 +269,28 @@ public: #else +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + impl_type * pi = std::allocator_traits<A2>::allocate( a2, 1 ); + pi_ = pi; + +#else + pi_ = a2.allocate( 1, static_cast< impl_type* >( 0 ) ); +#endif + if( pi_ != 0 ) { - new( static_cast< void* >( pi_ ) ) impl_type( p, d, a ); +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + std::allocator_traits<A2>::construct( a2, pi, p, d, a ); + +#else + + ::new( static_cast< void* >( pi_ ) ) impl_type( p, d, a ); + +#endif } else { @@ -234,20 +309,39 @@ public: #endif { typedef sp_counted_impl_pda< P, D, A > impl_type; + +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + typedef typename std::allocator_traits<A>::template rebind_alloc< impl_type > A2; + +#else + typedef typename A::template rebind< impl_type >::other A2; +#endif + A2 a2( a ); #ifndef BOOST_NO_EXCEPTIONS try { +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + impl_type * pi = std::allocator_traits<A2>::allocate( a2, 1 ); + pi_ = pi; + std::allocator_traits<A2>::construct( a2, pi, p, a ); + +#else + pi_ = a2.allocate( 1, static_cast< impl_type* >( 0 ) ); - new( static_cast< void* >( pi_ ) ) impl_type( p, a ); + ::new( static_cast< void* >( pi_ ) ) impl_type( p, a ); + +#endif } catch(...) { - D()( p ); + D::operator_fn( p ); if( pi_ != 0 ) { @@ -259,15 +353,32 @@ public: #else +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + impl_type * pi = std::allocator_traits<A2>::allocate( a2, 1 ); + pi_ = pi; + +#else + pi_ = a2.allocate( 1, static_cast< impl_type* >( 0 ) ); +#endif + if( pi_ != 0 ) { - new( static_cast< void* >( pi_ ) ) impl_type( p, a ); +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + std::allocator_traits<A2>::construct( a2, pi, p, a ); + +#else + + ::new( static_cast< void* >( pi_ ) ) impl_type( p, a ); + +#endif } else { - D()( p ); + D::operator_fn( p ); boost::throw_exception( std::bad_alloc() ); } @@ -300,6 +411,33 @@ public: #endif +#if !defined( BOOST_NO_CXX11_SMART_PTR ) + + template<class Y, class D> + explicit shared_count( std::unique_ptr<Y, D> & r ): pi_( 0 ) +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(shared_count_id) +#endif + { + typedef typename sp_convert_reference<D>::type D2; + + D2 d2( r.get_deleter() ); + pi_ = new sp_counted_impl_pd< typename std::unique_ptr<Y, D>::pointer, D2 >( r.get(), d2 ); + +#ifdef BOOST_NO_EXCEPTIONS + + if( pi_ == 0 ) + { + boost::throw_exception( std::bad_alloc() ); + } + +#endif + + r.release(); + } + +#endif + ~shared_count() // nothrow { if( pi_ != 0 ) pi_->release(); @@ -316,7 +454,7 @@ public: if( pi_ != 0 ) pi_->add_ref_copy(); } -#if defined( BOOST_HAS_RVALUE_REFS ) +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) shared_count(shared_count && r): pi_(r.pi_) // nothrow #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) @@ -381,6 +519,11 @@ public: { return pi_? pi_->get_deleter( ti ): 0; } + + void * get_untyped_deleter() const + { + return pi_? pi_->get_untyped_deleter(): 0; + } }; @@ -423,7 +566,7 @@ public: // Move support -#if defined( BOOST_HAS_RVALUE_REFS ) +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) weak_count(weak_count && r): pi_(r.pi_) // nothrow #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/shared_ptr_nmt.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/shared_ptr_nmt.hpp deleted file mode 100644 index afc1ec0..0000000 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/shared_ptr_nmt.hpp +++ /dev/null @@ -1,182 +0,0 @@ -#ifndef BOOST_SMART_PTR_DETAIL_SHARED_PTR_NMT_HPP_INCLUDED -#define BOOST_SMART_PTR_DETAIL_SHARED_PTR_NMT_HPP_INCLUDED - -// -// detail/shared_ptr_nmt.hpp - shared_ptr.hpp without member templates -// -// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. -// Copyright (c) 2001, 2002 Peter Dimov -// -// 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/smart_ptr/shared_ptr.htm for documentation. -// - -#include <boost/assert.hpp> -#include <boost/checked_delete.hpp> -#include <boost/throw_exception.hpp> -#include <boost/smart_ptr/detail/atomic_count.hpp> - -#ifndef BOOST_NO_AUTO_PTR -# include <memory> // for std::auto_ptr -#endif - -#include <algorithm> // for std::swap -#include <functional> // for std::less -#include <new> // for std::bad_alloc - -namespace boost -{ - -template<class T> class shared_ptr -{ -private: - - typedef detail::atomic_count count_type; - -public: - - typedef T element_type; - typedef T value_type; - - explicit shared_ptr(T * p = 0): px(p) - { -#ifndef BOOST_NO_EXCEPTIONS - - try // prevent leak if new throws - { - pn = new count_type(1); - } - catch(...) - { - boost::checked_delete(p); - throw; - } - -#else - - pn = new count_type(1); - - if(pn == 0) - { - boost::checked_delete(p); - boost::throw_exception(std::bad_alloc()); - } - -#endif - } - - ~shared_ptr() - { - if(--*pn == 0) - { - boost::checked_delete(px); - delete pn; - } - } - - shared_ptr(shared_ptr const & r): px(r.px) // never throws - { - pn = r.pn; - ++*pn; - } - - shared_ptr & operator=(shared_ptr const & r) - { - shared_ptr(r).swap(*this); - return *this; - } - -#ifndef BOOST_NO_AUTO_PTR - - explicit shared_ptr(std::auto_ptr<T> & r) - { - pn = new count_type(1); // may throw - px = r.release(); // fix: moved here to stop leak if new throws - } - - shared_ptr & operator=(std::auto_ptr<T> & r) - { - shared_ptr(r).swap(*this); - return *this; - } - -#endif - - void reset(T * p = 0) - { - BOOST_ASSERT(p == 0 || p != px); - shared_ptr(p).swap(*this); - } - - T & operator*() const // never throws - { - BOOST_ASSERT(px != 0); - return *px; - } - - T * operator->() const // never throws - { - BOOST_ASSERT(px != 0); - return px; - } - - T * get() const // never throws - { - return px; - } - - long use_count() const // never throws - { - return *pn; - } - - bool unique() const // never throws - { - return *pn == 1; - } - - void swap(shared_ptr<T> & other) // never throws - { - std::swap(px, other.px); - std::swap(pn, other.pn); - } - -private: - - T * px; // contained pointer - count_type * pn; // ptr to reference counter -}; - -template<class T, class U> inline bool operator==(shared_ptr<T> const & a, shared_ptr<U> const & b) -{ - return a.get() == b.get(); -} - -template<class T, class U> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<U> const & b) -{ - return a.get() != b.get(); -} - -template<class T> inline bool operator<(shared_ptr<T> const & a, shared_ptr<T> const & b) -{ - return std::less<T*>()(a.get(), b.get()); -} - -template<class T> void swap(shared_ptr<T> & a, shared_ptr<T> & b) -{ - a.swap(b); -} - -// get_pointer() enables boost::mem_fn to recognize shared_ptr - -template<class T> inline T * get_pointer(shared_ptr<T> const & p) -{ - return p.get(); -} - -} // namespace boost - -#endif // #ifndef BOOST_SMART_PTR_DETAIL_SHARED_PTR_NMT_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_convertible.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_convertible.hpp index eb39797..31b2627 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_convertible.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_convertible.hpp @@ -48,6 +48,21 @@ template< class Y, class T > struct sp_convertible enum _vt { value = sizeof( (f)( static_cast<Y*>(0) ) ) == sizeof(yes) }; }; +template< class Y, class T > struct sp_convertible< Y, T[] > +{ + enum _vt { value = false }; +}; + +template< class Y, class T > struct sp_convertible< Y[], T[] > +{ + enum _vt { value = sp_convertible< Y[1], T[1] >::value }; +}; + +template< class Y, std::size_t N, class T > struct sp_convertible< Y[N], T[] > +{ + enum _vt { value = sp_convertible< Y[1], T[1] >::value }; +}; + struct sp_empty { }; diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base.hpp index 24adfcc..c415892 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base.hpp @@ -10,7 +10,7 @@ // // detail/sp_counted_base.hpp // -// Copyright 2005, 2006 Peter Dimov +// Copyright 2005-2013 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -23,6 +23,9 @@ #if defined( BOOST_SP_DISABLE_THREADS ) # include <boost/smart_ptr/detail/sp_counted_base_nt.hpp> +#elif defined( BOOST_SP_USE_STD_ATOMIC ) +# include <boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp> + #elif defined( BOOST_SP_USE_SPINLOCK ) # include <boost/smart_ptr/detail/sp_counted_base_spin.hpp> @@ -32,25 +35,28 @@ #elif defined( BOOST_DISABLE_THREADS ) && !defined( BOOST_SP_ENABLE_THREADS ) && !defined( BOOST_DISABLE_WIN32 ) # include <boost/smart_ptr/detail/sp_counted_base_nt.hpp> -#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) -# include <boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp> +#elif defined( __SNC__ ) +# include <boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp> -#elif defined( __GNUC__ ) && defined( __ia64__ ) && !defined( __INTEL_COMPILER ) -# include <boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp> +#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) && !defined(__PATHSCALE__) +# include <boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp> #elif defined(__HP_aCC) && defined(__ia64) # include <boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp> +#elif defined( __GNUC__ ) && defined( __ia64__ ) && !defined( __INTEL_COMPILER ) && !defined(__PATHSCALE__) +# include <boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp> + #elif defined( __IBMCPP__ ) && defined( __powerpc ) # include <boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp> #elif defined( __MWERKS__ ) && defined( __POWERPC__ ) # include <boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp> -#elif defined( __GNUC__ ) && ( defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc ) ) +#elif defined( __GNUC__ ) && ( defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc ) ) && !defined(__PATHSCALE__) && !defined( _AIX ) # include <boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp> -#elif defined( __GNUC__ ) && ( defined( __mips__ ) || defined( _mips ) ) +#elif defined( __GNUC__ ) && ( defined( __mips__ ) || defined( _mips ) ) && !defined(__PATHSCALE__) # include <boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp> #elif defined( BOOST_SP_HAS_SYNC ) @@ -62,6 +68,9 @@ #elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined(__CYGWIN__) # include <boost/smart_ptr/detail/sp_counted_base_w32.hpp> +#elif defined( _AIX ) +# include <boost/smart_ptr/detail/sp_counted_base_aix.hpp> + #elif !defined( BOOST_HAS_THREADS ) # include <boost/smart_ptr/detail/sp_counted_base_nt.hpp> diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp index dffd995..cebc243 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp @@ -104,6 +104,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_aix.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_aix.hpp new file mode 100644 index 0000000..fe6c727 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_aix.hpp @@ -0,0 +1,143 @@ +#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_AIX_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_AIX_HPP_INCLUDED + +// +// detail/sp_counted_base_aix.hpp +// based on: detail/sp_counted_base_w32.hpp +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 Peter Dimov +// Copyright 2006 Michael van der Westhuizen +// +// 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) +// +// +// Lock-free algorithm by Alexander Terekhov +// +// Thanks to Ben Hitchings for the #weak + (#shared != 0) +// formulation +// + +#include <boost/detail/sp_typeinfo.hpp> +#include <builtins.h> +#include <sys/atomic_op.h> + +namespace boost +{ + +namespace detail +{ + +inline void atomic_increment( int32_t* pw ) +{ + // ++*pw; + + fetch_and_add( pw, 1 ); +} + +inline int32_t atomic_decrement( int32_t * pw ) +{ + // return --*pw; + + int32_t originalValue; + + __lwsync(); + originalValue = fetch_and_add( pw, -1 ); + __isync(); + + return (originalValue - 1); +} + +inline int32_t atomic_conditional_increment( int32_t * pw ) +{ + // if( *pw != 0 ) ++*pw; + // return *pw; + + int32_t tmp = fetch_and_add( pw, 0 ); + for( ;; ) + { + if( tmp == 0 ) return 0; + if( compare_and_swap( pw, &tmp, tmp + 1 ) ) return (tmp + 1); + } +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + int32_t use_count_; // #shared + int32_t weak_count_; // #weak + (#shared != 0) + +public: + + sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) + { + } + + virtual ~sp_counted_base() // nothrow + { + } + + // dispose() is called when use_count_ drops to zero, to release + // the resources managed by *this. + + virtual void dispose() = 0; // nothrow + + // destroy() is called when weak_count_ drops to zero. + + virtual void destroy() // nothrow + { + delete this; + } + + virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; + + void add_ref_copy() + { + atomic_increment( &use_count_ ); + } + + bool add_ref_lock() // true on success + { + return atomic_conditional_increment( &use_count_ ) != 0; + } + + void release() // nothrow + { + if( atomic_decrement( &use_count_ ) == 0 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + atomic_increment( &weak_count_ ); + } + + void weak_release() // nothrow + { + if( atomic_decrement( &weak_count_ ) == 0 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + return fetch_and_add( const_cast<int32_t*>(&use_count_), 0 ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_AIX_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp index 51ac56a..6c268e8 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp @@ -124,6 +124,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp index d122a49..f6e3904 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp @@ -111,6 +111,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp index 3f1f449..545c8ae 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp @@ -135,6 +135,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp index 7f5c414..2e5bc0e 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp @@ -135,6 +135,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp index 21fa59d..c6d20ce 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp @@ -120,6 +120,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp index 4d7fa8d..173dce5 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp @@ -127,6 +127,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_nt.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_nt.hpp index dfd70e7..5c901f9 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_nt.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_nt.hpp @@ -59,6 +59,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_pt.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_pt.hpp index 3c56fec..a16d2d8 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_pt.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_pt.hpp @@ -19,6 +19,7 @@ // #include <boost/detail/sp_typeinfo.hpp> +#include <boost/assert.hpp> #include <pthread.h> namespace boost @@ -46,15 +47,15 @@ public: // HPUX 10.20 / DCE has a nonstandard pthread_mutex_init #if defined(__hpux) && defined(_DECTHREADS_) - pthread_mutex_init( &m_, pthread_mutexattr_default ); + BOOST_VERIFY( pthread_mutex_init( &m_, pthread_mutexattr_default ) == 0 ); #else - pthread_mutex_init( &m_, 0 ); + BOOST_VERIFY( pthread_mutex_init( &m_, 0 ) == 0 ); #endif } virtual ~sp_counted_base() // nothrow { - pthread_mutex_destroy( &m_ ); + BOOST_VERIFY( pthread_mutex_destroy( &m_ ) == 0 ); } // dispose() is called when use_count_ drops to zero, to release @@ -70,27 +71,28 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { - pthread_mutex_lock( &m_ ); + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); ++use_count_; - pthread_mutex_unlock( &m_ ); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); } bool add_ref_lock() // true on success { - pthread_mutex_lock( &m_ ); + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); bool r = use_count_ == 0? false: ( ++use_count_, true ); - pthread_mutex_unlock( &m_ ); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); return r; } void release() // nothrow { - pthread_mutex_lock( &m_ ); + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); long new_use_count = --use_count_; - pthread_mutex_unlock( &m_ ); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); if( new_use_count == 0 ) { @@ -101,16 +103,16 @@ public: void weak_add_ref() // nothrow { - pthread_mutex_lock( &m_ ); + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); ++weak_count_; - pthread_mutex_unlock( &m_ ); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); } void weak_release() // nothrow { - pthread_mutex_lock( &m_ ); + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); long new_weak_count = --weak_count_; - pthread_mutex_unlock( &m_ ); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); if( new_weak_count == 0 ) { @@ -120,9 +122,9 @@ public: long use_count() const // nothrow { - pthread_mutex_lock( &m_ ); + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); long r = use_count_; - pthread_mutex_unlock( &m_ ); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); return r; } diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp new file mode 100644 index 0000000..56ed79f --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp @@ -0,0 +1,162 @@ +#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SNC_PS3_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SNC_PS3_HPP_INCLUDED + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// detail/sp_counted_base_gcc_sparc.hpp - g++ on Sparc V8+ +// +// Copyright (c) 2006 Piotr Wyderski +// Copyright (c) 2006 Tomas Puverle +// Copyright (c) 2006 Peter Dimov +// Copyright (c) 2011 Emil Dotchevski +// +// 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 +// +// Thanks to Michael van der Westhuizen + +#include <boost/detail/sp_typeinfo.hpp> +#include <inttypes.h> // uint32_t + +namespace boost +{ + +namespace detail +{ + +inline uint32_t compare_and_swap( uint32_t * dest_, uint32_t compare_, uint32_t swap_ ) +{ + return __builtin_cellAtomicCompareAndSwap32(dest_,compare_,swap_); +} + +inline uint32_t atomic_fetch_and_add( uint32_t * pw, uint32_t dv ) +{ + // long r = *pw; + // *pw += dv; + // return r; + + for( ;; ) + { + uint32_t r = *pw; + + if( __builtin_expect((compare_and_swap(pw, r, r + dv) == r), 1) ) + { + return r; + } + } +} + +inline void atomic_increment( uint32_t * pw ) +{ + (void) __builtin_cellAtomicIncr32( pw ); +} + +inline uint32_t atomic_decrement( uint32_t * pw ) +{ + return __builtin_cellAtomicDecr32( pw ); +} + +inline uint32_t atomic_conditional_increment( uint32_t * pw ) +{ + // long r = *pw; + // if( r != 0 ) ++*pw; + // return r; + + for( ;; ) + { + uint32_t r = *pw; + + if( r == 0 ) + { + return r; + } + + if( __builtin_expect( ( compare_and_swap( pw, r, r + 1 ) == r ), 1 ) ) + { + return r; + } + } +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + uint32_t use_count_; // #shared + uint32_t weak_count_; // #weak + (#shared != 0) + +public: + + sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) + { + } + + virtual ~sp_counted_base() // nothrow + { + } + + // dispose() is called when use_count_ drops to zero, to release + // the resources managed by *this. + + virtual void dispose() = 0; // nothrow + + // destroy() is called when weak_count_ drops to zero. + + virtual void destroy() // nothrow + { + delete this; + } + + virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; + + void add_ref_copy() + { + atomic_increment( &use_count_ ); + } + + bool add_ref_lock() // true on success + { + return atomic_conditional_increment( &use_count_ ) != 0; + } + + void release() // nothrow + { + if( atomic_decrement( &use_count_ ) == 1 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + atomic_increment( &weak_count_ ); + } + + void weak_release() // nothrow + { + if( atomic_decrement( &weak_count_ ) == 1 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + return const_cast< uint32_t const volatile & >( use_count_ ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SNC_PS3_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_spin.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_spin.hpp index bbd11e6..77734e7 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_spin.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_spin.hpp @@ -84,6 +84,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp new file mode 100644 index 0000000..cab8453 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp @@ -0,0 +1,137 @@ +#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_STD_ATOMIC_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_STD_ATOMIC_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// detail/sp_counted_base_std_atomic.hpp - C++11 std::atomic +// +// Copyright (c) 2007, 2013 Peter Dimov +// +// 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/detail/sp_typeinfo.hpp> +#include <atomic> +#include <cstdint> + +namespace boost +{ + +namespace detail +{ + +inline void atomic_increment( std::atomic_int_least32_t * pw ) +{ + pw->fetch_add( 1, std::memory_order_relaxed ); +} + +inline std::int_least32_t atomic_decrement( std::atomic_int_least32_t * pw ) +{ + return pw->fetch_sub( 1, std::memory_order_acq_rel ); +} + +inline std::int_least32_t atomic_conditional_increment( std::atomic_int_least32_t * pw ) +{ + // long r = *pw; + // if( r != 0 ) ++*pw; + // return r; + + std::int_least32_t r = pw->load( std::memory_order_relaxed ); + + for( ;; ) + { + if( r == 0 ) + { + return r; + } + + if( pw->compare_exchange_weak( r, r + 1, std::memory_order_relaxed, std::memory_order_relaxed ) ) + { + return r; + } + } +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + std::atomic_int_least32_t use_count_; // #shared + std::atomic_int_least32_t weak_count_; // #weak + (#shared != 0) + +public: + + sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) + { + } + + virtual ~sp_counted_base() // nothrow + { + } + + // dispose() is called when use_count_ drops to zero, to release + // the resources managed by *this. + + virtual void dispose() = 0; // nothrow + + // destroy() is called when weak_count_ drops to zero. + + virtual void destroy() // nothrow + { + delete this; + } + + virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; + + void add_ref_copy() + { + atomic_increment( &use_count_ ); + } + + bool add_ref_lock() // true on success + { + return atomic_conditional_increment( &use_count_ ) != 0; + } + + void release() // nothrow + { + if( atomic_decrement( &use_count_ ) == 1 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + atomic_increment( &weak_count_ ); + } + + void weak_release() // nothrow + { + if( atomic_decrement( &weak_count_ ) == 1 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + return use_count_.load( std::memory_order_acquire ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_STD_ATOMIC_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_sync.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_sync.hpp index 41f654e..fafed0e 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_sync.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_sync.hpp @@ -109,6 +109,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp index 842f58f..162f309 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp @@ -104,6 +104,7 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_w32.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_w32.hpp index 06aa456..4ba509c 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_w32.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_base_w32.hpp @@ -24,7 +24,7 @@ // formulation // -#include <boost/detail/interlocked.hpp> +#include <boost/smart_ptr/detail/sp_interlocked.hpp> #include <boost/detail/workaround.hpp> #include <boost/detail/sp_typeinfo.hpp> @@ -67,10 +67,11 @@ public: } virtual void * get_deleter( sp_typeinfo const & ti ) = 0; + virtual void * get_untyped_deleter() = 0; void add_ref_copy() { - BOOST_INTERLOCKED_INCREMENT( &use_count_ ); + BOOST_SP_INTERLOCKED_INCREMENT( &use_count_ ); } bool add_ref_lock() // true on success @@ -85,11 +86,11 @@ public: // work around a code generation bug long tmp2 = tmp + 1; - if( BOOST_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp2, tmp ) == tmp2 - 1 ) return true; + if( BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp2, tmp ) == tmp2 - 1 ) return true; #else - if( BOOST_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp + 1, tmp ) == tmp ) return true; + if( BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp + 1, tmp ) == tmp ) return true; #endif } @@ -97,7 +98,7 @@ public: void release() // nothrow { - if( BOOST_INTERLOCKED_DECREMENT( &use_count_ ) == 0 ) + if( BOOST_SP_INTERLOCKED_DECREMENT( &use_count_ ) == 0 ) { dispose(); weak_release(); @@ -106,12 +107,12 @@ public: void weak_add_ref() // nothrow { - BOOST_INTERLOCKED_INCREMENT( &weak_count_ ); + BOOST_SP_INTERLOCKED_INCREMENT( &weak_count_ ); } void weak_release() // nothrow { - if( BOOST_INTERLOCKED_DECREMENT( &weak_count_ ) == 0 ) + if( BOOST_SP_INTERLOCKED_DECREMENT( &weak_count_ ) == 0 ) { destroy(); } diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_impl.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_impl.hpp index aab39bd..a7b43ae 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_impl.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_counted_impl.hpp @@ -83,6 +83,11 @@ public: return 0; } + virtual void * get_untyped_deleter() + { + return 0; + } + #if defined(BOOST_SP_USE_STD_ALLOCATOR) void * operator new( std::size_t ) @@ -153,6 +158,11 @@ public: return ti == BOOST_SP_TYPEID(D)? &reinterpret_cast<char&>( del ): 0; } + virtual void * get_untyped_deleter() + { + return &reinterpret_cast<char&>( del ); + } + #if defined(BOOST_SP_USE_STD_ALLOCATOR) void * operator new( std::size_t ) @@ -203,7 +213,7 @@ public: { } - sp_counted_impl_pda( P p, A a ): p_( p ), d_(), a_( a ) + sp_counted_impl_pda( P p, A a ): p_( p ), d_( a ), a_( a ) { } @@ -214,11 +224,28 @@ public: virtual void destroy() // nothrow { +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + typedef typename std::allocator_traits<A>::template rebind_alloc< this_type > A2; + +#else + typedef typename A::template rebind< this_type >::other A2; +#endif + A2 a2( a_ ); +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + std::allocator_traits<A2>::destroy( a2, this ); + +#else + this->~this_type(); + +#endif + a2.deallocate( this, 1 ); } @@ -226,6 +253,11 @@ public: { return ti == BOOST_SP_TYPEID( D )? &reinterpret_cast<char&>( d_ ): 0; } + + virtual void * get_untyped_deleter() + { + return &reinterpret_cast<char&>( d_ ); + } }; #ifdef __CODEGUARD__ diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_forward.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_forward.hpp new file mode 100644 index 0000000..5f1d190 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_forward.hpp @@ -0,0 +1,39 @@ +#ifndef BOOST_SMART_PTR_DETAIL_SP_FORWARD_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_FORWARD_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// detail/sp_forward.hpp +// +// Copyright 2008,2012 Peter Dimov +// +// 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/config.hpp> + +namespace boost +{ + +namespace detail +{ + +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + +template< class T > T&& sp_forward( T & t ) BOOST_NOEXCEPT +{ + return static_cast< T&& >( t ); +} + +#endif + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_FORWARD_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_has_sync.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_has_sync.hpp index 12acea8..16de21d 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_has_sync.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_has_sync.hpp @@ -20,7 +20,17 @@ // are available. // -#if defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 401 ) && !defined( BOOST_SP_NO_SYNC ) +#ifndef BOOST_SP_NO_SYNC + +#if defined( __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 ) + +# define BOOST_SP_HAS_SYNC + +#elif defined( __IBMCPP__ ) && ( __IBMCPP__ >= 1210 ) + +# define BOOST_SP_HAS_SYNC + +#elif defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 401 ) #define BOOST_SP_HAS_SYNC @@ -44,10 +54,16 @@ #undef BOOST_SP_HAS_SYNC #endif -#if defined( __INTEL_COMPILER ) && !defined( __ia64__ ) && ( __INTEL_COMPILER < 1100 ) +#if defined( __INTEL_COMPILER ) && !defined( __ia64__ ) && ( __INTEL_COMPILER < 1110 ) #undef BOOST_SP_HAS_SYNC #endif -#endif // __GNUC__ * 100 + __GNUC_MINOR__ >= 401 +#if defined(__PATHSCALE__) && ((__PATHCC__ == 4) && (__PATHCC_MINOR__ < 9)) +#undef BOOST_SP_HAS_SYNC +#endif + +#endif + +#endif // #ifndef BOOST_SP_NO_SYNC #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_HAS_SYNC_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_if_array.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_if_array.hpp new file mode 100644 index 0000000..9a2c1e0 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_if_array.hpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2012-2014 Glen Joseph Fernandes + * glenfe at live dot com + * + * Distributed under the Boost Software License, + * Version 1.0. (See accompanying file LICENSE_1_0.txt + * or copy at http://boost.org/LICENSE_1_0.txt) + */ +#ifndef BOOST_SMART_PTR_DETAIL_SP_IF_ARRAY_HPP +#define BOOST_SMART_PTR_DETAIL_SP_IF_ARRAY_HPP + +#include <boost/smart_ptr/shared_ptr.hpp> + +namespace boost { + namespace detail { + template<class T> + struct sp_if_array; + + template<class T> + struct sp_if_array<T[]> { + typedef boost::shared_ptr<T[]> type; + }; + + template<class T> + struct sp_if_size_array; + + template<class T, std::size_t N> + struct sp_if_size_array<T[N]> { + typedef boost::shared_ptr<T[N]> type; + }; + } +} + +#endif diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_interlocked.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_interlocked.hpp new file mode 100644 index 0000000..814b0c2 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_interlocked.hpp @@ -0,0 +1,152 @@ +#ifndef BOOST_SMART_PTR_DETAIL_SP_INTERLOCKED_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_INTERLOCKED_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// boost/detail/sp_interlocked.hpp +// +// Copyright 2005, 2014 Peter Dimov +// +// 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/config.hpp> + +// BOOST_SP_HAS_INTRIN_H + +// VC9 has intrin.h, but it collides with <utility> +#if defined( BOOST_MSVC ) && BOOST_MSVC >= 1600 + +# define BOOST_SP_HAS_INTRIN_H + +// Unlike __MINGW64__, __MINGW64_VERSION_MAJOR is defined by MinGW-w64 for both 32 and 64-bit targets. +#elif defined( __MINGW64_VERSION_MAJOR ) + +// MinGW-w64 provides intrin.h for both 32 and 64-bit targets. +# define BOOST_SP_HAS_INTRIN_H + +// Intel C++ on Windows on VC10+ stdlib +#elif defined( BOOST_INTEL_WIN ) && defined( _CPPLIB_VER ) && _CPPLIB_VER >= 520 + +# define BOOST_SP_HAS_INTRIN_H + +#endif + +#if defined( BOOST_USE_WINDOWS_H ) + +# include <windows.h> + +# define BOOST_SP_INTERLOCKED_INCREMENT InterlockedIncrement +# define BOOST_SP_INTERLOCKED_DECREMENT InterlockedDecrement +# define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE InterlockedExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd + +#elif defined( BOOST_USE_INTRIN_H ) || defined( BOOST_SP_HAS_INTRIN_H ) + +#include <intrin.h> + +# define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement +# define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement +# define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd + +#elif defined( _WIN32_WCE ) + +#if _WIN32_WCE >= 0x600 + +extern "C" long __cdecl _InterlockedIncrement( long volatile * ); +extern "C" long __cdecl _InterlockedDecrement( long volatile * ); +extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long ); +extern "C" long __cdecl _InterlockedExchange( long volatile *, long ); +extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long ); + +# define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement +# define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement +# define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd + +#else + +// under Windows CE we still have old-style Interlocked* functions + +extern "C" long __cdecl InterlockedIncrement( long* ); +extern "C" long __cdecl InterlockedDecrement( long* ); +extern "C" long __cdecl InterlockedCompareExchange( long*, long, long ); +extern "C" long __cdecl InterlockedExchange( long*, long ); +extern "C" long __cdecl InterlockedExchangeAdd( long*, long ); + +# define BOOST_SP_INTERLOCKED_INCREMENT InterlockedIncrement +# define BOOST_SP_INTERLOCKED_DECREMENT InterlockedDecrement +# define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE InterlockedExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd + +#endif + +#elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN ) + +#if defined( __CLRCALL_PURE_OR_CDECL ) + +extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedIncrement( long volatile * ); +extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedDecrement( long volatile * ); +extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedCompareExchange( long volatile *, long, long ); +extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchange( long volatile *, long ); +extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchangeAdd( long volatile *, long ); + +#else + +extern "C" long __cdecl _InterlockedIncrement( long volatile * ); +extern "C" long __cdecl _InterlockedDecrement( long volatile * ); +extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long ); +extern "C" long __cdecl _InterlockedExchange( long volatile *, long ); +extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long ); + +#endif + +# define BOOST_SP_INTERLOCKED_INCREMENT _InterlockedIncrement +# define BOOST_SP_INTERLOCKED_DECREMENT _InterlockedDecrement +# define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE _InterlockedExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd + +#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ ) + +namespace boost +{ + +namespace detail +{ + +extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement( long volatile * ); +extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement( long volatile * ); +extern "C" __declspec(dllimport) long __stdcall InterlockedCompareExchange( long volatile *, long, long ); +extern "C" __declspec(dllimport) long __stdcall InterlockedExchange( long volatile *, long ); +extern "C" __declspec(dllimport) long __stdcall InterlockedExchangeAdd( long volatile *, long ); + +} // namespace detail + +} // namespace boost + +# define BOOST_SP_INTERLOCKED_INCREMENT ::boost::detail::InterlockedIncrement +# define BOOST_SP_INTERLOCKED_DECREMENT ::boost::detail::InterlockedDecrement +# define BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE ::boost::detail::InterlockedCompareExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE ::boost::detail::InterlockedExchange +# define BOOST_SP_INTERLOCKED_EXCHANGE_ADD ::boost::detail::InterlockedExchangeAdd + +#else + +# error "Interlocked intrinsics not available" + +#endif + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_INTERLOCKED_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/sp_nullptr_t.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_nullptr_t.hpp new file mode 100644 index 0000000..ccbb123 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/sp_nullptr_t.hpp @@ -0,0 +1,45 @@ +#ifndef BOOST_SMART_PTR_DETAIL_SP_NULLPTR_T_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_NULLPTR_T_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// detail/sp_nullptr_t.hpp +// +// Copyright 2013 Peter Dimov +// +// 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/config.hpp> +#include <cstddef> + +#if !defined( BOOST_NO_CXX11_NULLPTR ) + +namespace boost +{ + +namespace detail +{ + +#if defined( __clang__ ) && !defined( _LIBCPP_VERSION ) && !defined( BOOST_NO_CXX11_DECLTYPE ) + + typedef decltype(nullptr) sp_nullptr_t; + +#else + + typedef std::nullptr_t sp_nullptr_t; + +#endif + +} // namespace detail + +} // namespace boost + +#endif // !defined( BOOST_NO_CXX11_NULLPTR ) + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_NULLPTR_T_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock.hpp index 88d7ad6..19f93d7 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock.hpp @@ -31,7 +31,16 @@ #include <boost/config.hpp> #include <boost/smart_ptr/detail/sp_has_sync.hpp> -#if defined( BOOST_SP_USE_PTHREADS ) +#if defined( BOOST_SP_USE_STD_ATOMIC ) +# if !defined( __clang__ ) +# include <boost/smart_ptr/detail/spinlock_std_atomic.hpp> +# else +// Clang (at least up to 3.4) can't compile spinlock_pool when +// using std::atomic, so substitute the __sync implementation instead. +# include <boost/smart_ptr/detail/spinlock_sync.hpp> +# endif + +#elif defined( BOOST_SP_USE_PTHREADS ) # include <boost/smart_ptr/detail/spinlock_pt.hpp> #elif defined(__GNUC__) && defined( __arm__ ) && !defined( __thumb__ ) diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_gcc_arm.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_gcc_arm.hpp index f1bbaf6..016796a 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_gcc_arm.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_gcc_arm.hpp @@ -11,13 +11,15 @@ #include <boost/smart_ptr/detail/yield_k.hpp> -#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) +#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7S__) # define BOOST_SP_ARM_BARRIER "dmb" +# define BOOST_SP_ARM_HAS_LDREX #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) # define BOOST_SP_ARM_BARRIER "mcr p15, 0, r0, c7, c10, 5" +# define BOOST_SP_ARM_HAS_LDREX #else @@ -43,17 +45,7 @@ public: { int r; -#if defined(__ARM_ARCH_6__) \ - || defined(__ARM_ARCH_6J__) \ - || defined(__ARM_ARCH_6K__) \ - || defined(__ARM_ARCH_6Z__) \ - || defined(__ARM_ARCH_6ZK__) \ - || defined(__ARM_ARCH_6T2__) \ - || defined(__ARM_ARCH_7__) \ - || defined(__ARM_ARCH_7A__) \ - || defined(__ARM_ARCH_7R__) \ - || defined(__ARM_ARCH_7M__) \ - || defined(__ARM_ARCH_7EM__) +#ifdef BOOST_SP_ARM_HAS_LDREX __asm__ __volatile__( "ldrex %0, [%2]; \n" @@ -123,5 +115,6 @@ public: #define BOOST_DETAIL_SPINLOCK_INIT {0} #undef BOOST_SP_ARM_BARRIER +#undef BOOST_SP_ARM_HAS_LDREX #endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_std_atomic.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_std_atomic.hpp new file mode 100644 index 0000000..a61c1cd --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_std_atomic.hpp @@ -0,0 +1,83 @@ +#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_STD_ATOMIC_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SPINLOCK_STD_ATOMIC_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// Copyright (c) 2014 Peter Dimov +// +// 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/smart_ptr/detail/yield_k.hpp> +#include <atomic> + +namespace boost +{ + +namespace detail +{ + +class spinlock +{ +public: + + std::atomic_flag v_; + +public: + + bool try_lock() + { + return !v_.test_and_set( std::memory_order_acquire ); + } + + void lock() + { + for( unsigned k = 0; !try_lock(); ++k ) + { + boost::detail::yield( k ); + } + } + + void unlock() + { + v_ .clear( std::memory_order_release ); + } + +public: + + class scoped_lock + { + private: + + spinlock & sp_; + + scoped_lock( scoped_lock const & ); + scoped_lock & operator=( scoped_lock const & ); + + public: + + explicit scoped_lock( spinlock & sp ): sp_( sp ) + { + sp.lock(); + } + + ~scoped_lock() + { + sp_.unlock(); + } + }; +}; + +} // namespace detail +} // namespace boost + +#define BOOST_DETAIL_SPINLOCK_INIT { ATOMIC_FLAG_INIT } + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_STD_ATOMIC_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_w32.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_w32.hpp index fb97629..d34e4fc 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_w32.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/spinlock_w32.hpp @@ -15,7 +15,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // -#include <boost/detail/interlocked.hpp> +#include <boost/smart_ptr/detail/sp_interlocked.hpp> #include <boost/smart_ptr/detail/yield_k.hpp> // BOOST_COMPILER_FENCE @@ -59,7 +59,7 @@ public: bool try_lock() { - long r = BOOST_INTERLOCKED_EXCHANGE( &v_, 1 ); + long r = BOOST_SP_INTERLOCKED_EXCHANGE( &v_, 1 ); BOOST_COMPILER_FENCE diff --git a/3rdParty/Boost/src/boost/smart_ptr/detail/yield_k.hpp b/3rdParty/Boost/src/boost/smart_ptr/detail/yield_k.hpp index 23eadd8..9f4496b 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/detail/yield_k.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/detail/yield_k.hpp @@ -11,6 +11,7 @@ // yield_k.hpp // // Copyright (c) 2008 Peter Dimov +// Copyright (c) Microsoft Corporation 2014 // // void yield( unsigned k ); // @@ -24,13 +25,17 @@ // #include <boost/config.hpp> +#include <boost/predef.h> + +#if BOOST_PLAT_WINDOWS_RUNTIME +#include <thread> +#endif // BOOST_SMT_PAUSE #if defined(_MSC_VER) && _MSC_VER >= 1310 && ( defined(_M_IX86) || defined(_M_X64) ) extern "C" void _mm_pause(); -#pragma intrinsic( _mm_pause ) #define BOOST_SMT_PAUSE _mm_pause(); @@ -54,7 +59,7 @@ namespace boost namespace detail { -#if !defined( BOOST_USE_WINDOWS_H ) +#if !defined( BOOST_USE_WINDOWS_H ) && !BOOST_PLAT_WINDOWS_RUNTIME extern "C" void __stdcall Sleep( unsigned long ms ); #endif @@ -69,6 +74,7 @@ inline void yield( unsigned k ) BOOST_SMT_PAUSE } #endif +#if !BOOST_PLAT_WINDOWS_RUNTIME else if( k < 32 ) { Sleep( 0 ); @@ -77,6 +83,13 @@ inline void yield( unsigned k ) { Sleep( 1 ); } +#else + else + { + // Sleep isn't supported on the Windows Runtime. + std::this_thread::yield(); + } +#endif } } // namespace detail diff --git a/3rdParty/Boost/src/boost/smart_ptr/enable_shared_from_this.hpp b/3rdParty/Boost/src/boost/smart_ptr/enable_shared_from_this.hpp index f7b1445..3230f02 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/enable_shared_from_this.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/enable_shared_from_this.hpp @@ -25,20 +25,20 @@ template<class T> class enable_shared_from_this { protected: - enable_shared_from_this() + enable_shared_from_this() BOOST_NOEXCEPT { } - enable_shared_from_this(enable_shared_from_this const &) + enable_shared_from_this(enable_shared_from_this const &) BOOST_NOEXCEPT { } - enable_shared_from_this & operator=(enable_shared_from_this const &) + enable_shared_from_this & operator=(enable_shared_from_this const &) BOOST_NOEXCEPT { return *this; } - ~enable_shared_from_this() + ~enable_shared_from_this() BOOST_NOEXCEPT // ~weak_ptr<T> newer throws, so this call also must not throw { } diff --git a/3rdParty/Boost/src/boost/smart_ptr/intrusive_ptr.hpp b/3rdParty/Boost/src/boost/smart_ptr/intrusive_ptr.hpp index a575223..e5db609 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/intrusive_ptr.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/intrusive_ptr.hpp @@ -18,6 +18,7 @@ #include <boost/assert.hpp> #include <boost/detail/workaround.hpp> #include <boost/smart_ptr/detail/sp_convertible.hpp> +#include <boost/smart_ptr/detail/sp_nullptr_t.hpp> #include <boost/config/no_tr1/functional.hpp> // for std::less @@ -58,7 +59,7 @@ public: typedef T element_type; - intrusive_ptr(): px( 0 ) + intrusive_ptr() BOOST_NOEXCEPT : px( 0 ) { } @@ -108,14 +109,14 @@ public: // Move support -#if defined( BOOST_HAS_RVALUE_REFS ) +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) - intrusive_ptr(intrusive_ptr && rhs): px( rhs.px ) + intrusive_ptr(intrusive_ptr && rhs) BOOST_NOEXCEPT : px( rhs.px ) { rhs.px = 0; } - intrusive_ptr & operator=(intrusive_ptr && rhs) + intrusive_ptr & operator=(intrusive_ptr && rhs) BOOST_NOEXCEPT { this_type( static_cast< intrusive_ptr && >( rhs ) ).swap(*this); return *this; @@ -135,7 +136,7 @@ public: return *this; } - void reset() + void reset() BOOST_NOEXCEPT { this_type().swap( *this ); } @@ -145,11 +146,23 @@ public: this_type( rhs ).swap( *this ); } - T * get() const + void reset( T * rhs, bool add_ref ) + { + this_type( rhs, add_ref ).swap( *this ); + } + + T * get() const BOOST_NOEXCEPT { return px; } + T * detach() BOOST_NOEXCEPT + { + T * ret = px; + px = 0; + return ret; + } + T & operator*() const { BOOST_ASSERT( px != 0 ); @@ -165,7 +178,7 @@ public: // implicit conversion to "bool" #include <boost/smart_ptr/detail/operator_bool.hpp> - void swap(intrusive_ptr & rhs) + void swap(intrusive_ptr & rhs) BOOST_NOEXCEPT { T * tmp = px; px = rhs.px; @@ -218,6 +231,30 @@ template<class T> inline bool operator!=(intrusive_ptr<T> const & a, intrusive_p #endif +#if !defined( BOOST_NO_CXX11_NULLPTR ) + +template<class T> inline bool operator==( intrusive_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +{ + return p.get() == 0; +} + +template<class T> inline bool operator==( boost::detail::sp_nullptr_t, intrusive_ptr<T> const & p ) BOOST_NOEXCEPT +{ + return p.get() == 0; +} + +template<class T> inline bool operator!=( intrusive_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +{ + return p.get() != 0; +} + +template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, intrusive_ptr<T> const & p ) BOOST_NOEXCEPT +{ + return p.get() != 0; +} + +#endif + template<class T> inline bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) { return std::less<T *>()(a.get(), b.get()); diff --git a/3rdParty/Boost/src/boost/smart_ptr/make_shared.hpp b/3rdParty/Boost/src/boost/smart_ptr/make_shared.hpp index 7b605e2..8d0e3ea 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/make_shared.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/make_shared.hpp @@ -3,7 +3,7 @@ // make_shared.hpp // -// Copyright (c) 2007, 2008 Peter Dimov +// Copyright (c) 2007, 2008, 2012 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -12,970 +12,11 @@ // See http://www.boost.org/libs/smart_ptr/make_shared.html // for documentation. -#include <boost/config.hpp> -#include <boost/smart_ptr/shared_ptr.hpp> -#include <boost/type_traits/type_with_alignment.hpp> -#include <boost/type_traits/alignment_of.hpp> -#include <cstddef> -#include <new> - -namespace boost -{ - -namespace detail -{ - -template< std::size_t N, std::size_t A > struct sp_aligned_storage -{ - union type - { - char data_[ N ]; - typename boost::type_with_alignment< A >::type align_; - }; -}; - -template< class T > class sp_ms_deleter -{ -private: - - typedef typename sp_aligned_storage< sizeof( T ), ::boost::alignment_of< T >::value >::type storage_type; - - bool initialized_; - storage_type storage_; - -private: - - void destroy() - { - if( initialized_ ) - { -#if defined( __GNUC__ ) - - // fixes incorrect aliasing warning - T * p = reinterpret_cast< T* >( storage_.data_ ); - p->~T(); - -#else - - reinterpret_cast< T* >( storage_.data_ )->~T(); - -#endif - - initialized_ = false; - } - } - -public: - - sp_ms_deleter(): initialized_( false ) - { - } - - // optimization: do not copy storage_ - sp_ms_deleter( sp_ms_deleter const & ): initialized_( false ) - { - } - - ~sp_ms_deleter() - { - destroy(); - } - - void operator()( T * ) - { - destroy(); - } - - void * address() - { - return storage_.data_; - } - - void set_initialized() - { - initialized_ = true; - } -}; - -#if defined( BOOST_HAS_RVALUE_REFS ) - -template< class T > T&& sp_forward( T & t ) -{ - return static_cast< T&& >( t ); -} - -#endif - -} // namespace detail - -#if !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING ) -# define BOOST_SP_MSD( T ) boost::detail::sp_inplace_tag< boost::detail::sp_ms_deleter< T > >() -#else -# define BOOST_SP_MSD( T ) boost::detail::sp_ms_deleter< T >() -#endif - -// Zero-argument versions -// -// Used even when variadic templates are available because of the new T() vs new T issue - -template< class T > boost::shared_ptr< T > make_shared() -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T(); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A > boost::shared_ptr< T > allocate_shared( A const & a ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T(); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -#if defined( BOOST_HAS_VARIADIC_TMPL ) && defined( BOOST_HAS_RVALUE_REFS ) - -// Variadic templates, rvalue reference - -template< class T, class Arg1, class... Args > boost::shared_ptr< T > make_shared( Arg1 && arg1, Args && ... args ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( boost::detail::sp_forward<Arg1>( arg1 ), boost::detail::sp_forward<Args>( args )... ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class Arg1, class... Args > boost::shared_ptr< T > allocate_shared( A const & a, Arg1 && arg1, Args && ... args ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( boost::detail::sp_forward<Arg1>( arg1 ), boost::detail::sp_forward<Args>( args )... ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -#elif defined( BOOST_HAS_RVALUE_REFS ) - -// For example MSVC 10.0 - -template< class T, class A1 > -boost::shared_ptr< T > make_shared( A1 && a1 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 && a1 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2 > -boost::shared_ptr< T > make_shared( A1 && a1, A2 && a2 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 && a1, A2 && a2 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2, class A3 > -boost::shared_ptr< T > make_shared( A1 && a1, A2 && a2, A3 && a3 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ), - boost::detail::sp_forward<A3>( a3 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2, class A3 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ), - boost::detail::sp_forward<A3>( a3 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2, class A3, class A4 > -boost::shared_ptr< T > make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ), - boost::detail::sp_forward<A3>( a3 ), - boost::detail::sp_forward<A4>( a4 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2, class A3, class A4 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ), - boost::detail::sp_forward<A3>( a3 ), - boost::detail::sp_forward<A4>( a4 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2, class A3, class A4, class A5 > -boost::shared_ptr< T > make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ), - boost::detail::sp_forward<A3>( a3 ), - boost::detail::sp_forward<A4>( a4 ), - boost::detail::sp_forward<A5>( a5 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2, class A3, class A4, class A5 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ), - boost::detail::sp_forward<A3>( a3 ), - boost::detail::sp_forward<A4>( a4 ), - boost::detail::sp_forward<A5>( a5 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2, class A3, class A4, class A5, class A6 > -boost::shared_ptr< T > make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ), - boost::detail::sp_forward<A3>( a3 ), - boost::detail::sp_forward<A4>( a4 ), - boost::detail::sp_forward<A5>( a5 ), - boost::detail::sp_forward<A6>( a6 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ), - boost::detail::sp_forward<A3>( a3 ), - boost::detail::sp_forward<A4>( a4 ), - boost::detail::sp_forward<A5>( a5 ), - boost::detail::sp_forward<A6>( a6 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > -boost::shared_ptr< T > make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ), - boost::detail::sp_forward<A3>( a3 ), - boost::detail::sp_forward<A4>( a4 ), - boost::detail::sp_forward<A5>( a5 ), - boost::detail::sp_forward<A6>( a6 ), - boost::detail::sp_forward<A7>( a7 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ), - boost::detail::sp_forward<A3>( a3 ), - boost::detail::sp_forward<A4>( a4 ), - boost::detail::sp_forward<A5>( a5 ), - boost::detail::sp_forward<A6>( a6 ), - boost::detail::sp_forward<A7>( a7 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > -boost::shared_ptr< T > make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ), - boost::detail::sp_forward<A3>( a3 ), - boost::detail::sp_forward<A4>( a4 ), - boost::detail::sp_forward<A5>( a5 ), - boost::detail::sp_forward<A6>( a6 ), - boost::detail::sp_forward<A7>( a7 ), - boost::detail::sp_forward<A8>( a8 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ), - boost::detail::sp_forward<A3>( a3 ), - boost::detail::sp_forward<A4>( a4 ), - boost::detail::sp_forward<A5>( a5 ), - boost::detail::sp_forward<A6>( a6 ), - boost::detail::sp_forward<A7>( a7 ), - boost::detail::sp_forward<A8>( a8 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > -boost::shared_ptr< T > make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8, A9 && a9 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ), - boost::detail::sp_forward<A3>( a3 ), - boost::detail::sp_forward<A4>( a4 ), - boost::detail::sp_forward<A5>( a5 ), - boost::detail::sp_forward<A6>( a6 ), - boost::detail::sp_forward<A7>( a7 ), - boost::detail::sp_forward<A8>( a8 ), - boost::detail::sp_forward<A9>( a9 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8, A9 && a9 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( - boost::detail::sp_forward<A1>( a1 ), - boost::detail::sp_forward<A2>( a2 ), - boost::detail::sp_forward<A3>( a3 ), - boost::detail::sp_forward<A4>( a4 ), - boost::detail::sp_forward<A5>( a5 ), - boost::detail::sp_forward<A6>( a6 ), - boost::detail::sp_forward<A7>( a7 ), - boost::detail::sp_forward<A8>( a8 ), - boost::detail::sp_forward<A9>( a9 ) - ); - - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -#else - -// C++03 version - -template< class T, class A1 > -boost::shared_ptr< T > make_shared( A1 const & a1 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2 > -boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2, class A3 > -boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2, class A3 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2, class A3, class A4 > -boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2, class A3, class A4 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2, class A3, class A4, class A5 > -boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2, class A3, class A4, class A5 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2, class A3, class A4, class A5, class A6 > -boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, a6 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, a6 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > -boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > -boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > -boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8, A9 const & a9 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} - -template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > -boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8, A9 const & a9 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); - pd->set_initialized(); - - T * pt2 = static_cast< T* >( pv ); - - boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); - return boost::shared_ptr< T >( pt, pt2 ); -} +#include <boost/smart_ptr/make_shared_object.hpp> +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined( BOOST_NO_SFINAE ) +# include <boost/smart_ptr/make_shared_array.hpp> +# include <boost/smart_ptr/allocate_shared_array.hpp> #endif -#undef BOOST_SP_MSD - -} // namespace boost - #endif // #ifndef BOOST_SMART_PTR_MAKE_SHARED_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/make_shared_array.hpp b/3rdParty/Boost/src/boost/smart_ptr/make_shared_array.hpp new file mode 100644 index 0000000..c48f507 --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/make_shared_array.hpp @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2012-2014 Glen Joseph Fernandes + * glenfe at live dot com + * + * Distributed under the Boost Software License, + * Version 1.0. (See accompanying file LICENSE_1_0.txt + * or copy at http://boost.org/LICENSE_1_0.txt) + */ +#ifndef BOOST_SMART_PTR_MAKE_SHARED_ARRAY_HPP +#define BOOST_SMART_PTR_MAKE_SHARED_ARRAY_HPP + +#include <boost/smart_ptr/detail/array_count_impl.hpp> +#include <boost/smart_ptr/detail/sp_if_array.hpp> + +namespace boost { + template<class T> + inline typename boost::detail::sp_if_array<T>::type + make_shared(std::size_t size) { + typedef typename boost::detail::array_inner<T>::type T1; + typedef typename boost::detail::array_base<T1>::type T2; + typedef boost::detail::ms_allocator<T> A1; + typedef boost::detail::ms_in_allocator_tag D1; + std::size_t n1 = size * boost::detail::array_total<T1>::size; + T1* p1 = 0; + T2* p2 = 0; + D1 d1; + A1 a1(size, &p2); + shared_ptr<T> s1(p1, d1, a1); + A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter()); + a2->set(0); + boost::detail::ms_init(p2, n1); + a2->set(p2); + p1 = reinterpret_cast<T1*>(p2); + return shared_ptr<T>(s1, p1); + } + + template<class T> + inline typename boost::detail::sp_if_size_array<T>::type + make_shared() { + typedef typename boost::detail::array_inner<T>::type T1; + typedef typename boost::detail::array_base<T1>::type T2; + typedef boost::detail::ms_allocator<T> A1; + typedef boost::detail::ms_in_allocator_tag D1; + enum { + N = boost::detail::array_total<T>::size + }; + T1* p1 = 0; + T2* p2 = 0; + D1 d1; + A1 a1(&p2); + shared_ptr<T> s1(p1, d1, a1); + A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter()); + a2->set(0); + boost::detail::ms_init(p2, N); + a2->set(p2); + p1 = reinterpret_cast<T1*>(p2); + return shared_ptr<T>(s1, p1); + } + + template<class T> + inline typename boost::detail::sp_if_array<T>::type + make_shared(std::size_t size, + const typename boost::detail::array_inner<T>::type& value) { + typedef typename boost::detail::array_inner<T>::type T1; + typedef typename boost::detail::array_base<T1>::type T2; + typedef const T2 T3; + typedef boost::detail::ms_allocator<T> A1; + typedef boost::detail::ms_in_allocator_tag D1; + enum { + M = boost::detail::array_total<T1>::size + }; + std::size_t n1 = M * size; + T1* p1 = 0; + T2* p2 = 0; + T3* p3 = reinterpret_cast<T3*>(&value); + D1 d1; + A1 a1(size, &p2); + shared_ptr<T> s1(p1, d1, a1); + A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter()); + a2->set(0); + boost::detail::ms_init<T2, M>(p2, n1, p3); + a2->set(p2); + p1 = reinterpret_cast<T1*>(p2); + return shared_ptr<T>(s1, p1); + } + + template<class T> + inline typename boost::detail::sp_if_size_array<T>::type + make_shared(const typename boost::detail::array_inner<T>::type& value) { + typedef typename boost::detail::array_inner<T>::type T1; + typedef typename boost::detail::array_base<T1>::type T2; + typedef const T2 T3; + typedef boost::detail::ms_allocator<T> A1; + typedef boost::detail::ms_in_allocator_tag D1; + enum { + M = boost::detail::array_total<T1>::size, + N = boost::detail::array_total<T>::size + }; + T1* p1 = 0; + T2* p2 = 0; + T3* p3 = reinterpret_cast<T3*>(&value); + D1 d1; + A1 a1(&p2); + shared_ptr<T> s1(p1, d1, a1); + A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter()); + a2->set(0); + boost::detail::ms_init<T2, M>(p2, N, p3); + a2->set(p2); + p1 = reinterpret_cast<T1*>(p2); + return shared_ptr<T>(s1, p1); + } + + template<class T> + inline typename boost::detail::sp_if_array<T>::type + make_shared_noinit(std::size_t size) { + typedef typename boost::detail::array_inner<T>::type T1; + typedef typename boost::detail::array_base<T1>::type T2; + typedef boost::detail::ms_allocator<T> A1; + typedef boost::detail::ms_in_allocator_tag D1; + std::size_t n1 = size * boost::detail::array_total<T1>::size; + T1* p1 = 0; + T2* p2 = 0; + D1 d1; + A1 a1(size, &p2); + shared_ptr<T> s1(p1, d1, a1); + A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter()); + a2->set(0); + boost::detail::ms_noinit(p2, n1); + a2->set(p2); + p1 = reinterpret_cast<T1*>(p2); + return shared_ptr<T>(s1, p1); + } + + template<class T> + inline typename boost::detail::sp_if_size_array<T>::type + make_shared_noinit() { + typedef typename boost::detail::array_inner<T>::type T1; + typedef typename boost::detail::array_base<T1>::type T2; + typedef boost::detail::ms_allocator<T> A1; + typedef boost::detail::ms_in_allocator_tag D1; + enum { + N = boost::detail::array_total<T>::size + }; + T1* p1 = 0; + T2* p2 = 0; + D1 d1; + A1 a1(&p2); + shared_ptr<T> s1(p1, d1, a1); + A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter()); + a2->set(0); + boost::detail::ms_noinit(p2, N); + a2->set(p2); + p1 = reinterpret_cast<T1*>(p2); + return shared_ptr<T>(s1, p1); + } +} + +#endif diff --git a/3rdParty/Boost/src/boost/smart_ptr/make_shared_object.hpp b/3rdParty/Boost/src/boost/smart_ptr/make_shared_object.hpp new file mode 100644 index 0000000..62372fa --- /dev/null +++ b/3rdParty/Boost/src/boost/smart_ptr/make_shared_object.hpp @@ -0,0 +1,1131 @@ +#ifndef BOOST_SMART_PTR_MAKE_SHARED_OBJECT_HPP_INCLUDED +#define BOOST_SMART_PTR_MAKE_SHARED_OBJECT_HPP_INCLUDED + +// make_shared_object.hpp +// +// Copyright (c) 2007, 2008, 2012 Peter Dimov +// +// 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/smart_ptr/make_shared.html +// for documentation. + +#include <boost/config.hpp> +#include <boost/smart_ptr/shared_ptr.hpp> +#include <boost/smart_ptr/detail/sp_forward.hpp> +#include <boost/type_traits/type_with_alignment.hpp> +#include <boost/type_traits/alignment_of.hpp> +#include <cstddef> +#include <new> + +namespace boost +{ + +namespace detail +{ + +template< std::size_t N, std::size_t A > struct sp_aligned_storage +{ + union type + { + char data_[ N ]; + typename boost::type_with_alignment< A >::type align_; + }; +}; + +template< class T > class sp_ms_deleter +{ +private: + + typedef typename sp_aligned_storage< sizeof( T ), ::boost::alignment_of< T >::value >::type storage_type; + + bool initialized_; + storage_type storage_; + +private: + + void destroy() + { + if( initialized_ ) + { +#if defined( __GNUC__ ) + + // fixes incorrect aliasing warning + T * p = reinterpret_cast< T* >( storage_.data_ ); + p->~T(); + +#else + + reinterpret_cast< T* >( storage_.data_ )->~T(); + +#endif + + initialized_ = false; + } + } + +public: + + sp_ms_deleter() BOOST_NOEXCEPT : initialized_( false ) + { + } + + template<class A> explicit sp_ms_deleter( A const & ) BOOST_NOEXCEPT : initialized_( false ) + { + } + + // optimization: do not copy storage_ + sp_ms_deleter( sp_ms_deleter const & ) BOOST_NOEXCEPT : initialized_( false ) + { + } + + ~sp_ms_deleter() + { + destroy(); + } + + void operator()( T * ) + { + destroy(); + } + + static void operator_fn( T* ) // operator() can't be static + { + } + + void * address() BOOST_NOEXCEPT + { + return storage_.data_; + } + + void set_initialized() BOOST_NOEXCEPT + { + initialized_ = true; + } +}; + +template< class T, class A > class sp_as_deleter +{ +private: + + typedef typename sp_aligned_storage< sizeof( T ), ::boost::alignment_of< T >::value >::type storage_type; + + storage_type storage_; + A a_; + bool initialized_; + +private: + + void destroy() + { + if( initialized_ ) + { + T * p = reinterpret_cast< T* >( storage_.data_ ); + +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + std::allocator_traits<A>::destroy( a_, p ); + +#else + + p->~T(); + +#endif + + initialized_ = false; + } + } + +public: + + sp_as_deleter( A const & a ) BOOST_NOEXCEPT : a_( a ), initialized_( false ) + { + } + + // optimization: do not copy storage_ + sp_as_deleter( sp_as_deleter const & r ) BOOST_NOEXCEPT : a_( r.a_), initialized_( false ) + { + } + + ~sp_as_deleter() + { + destroy(); + } + + void operator()( T * ) + { + destroy(); + } + + static void operator_fn( T* ) // operator() can't be static + { + } + + void * address() BOOST_NOEXCEPT + { + return storage_.data_; + } + + void set_initialized() BOOST_NOEXCEPT + { + initialized_ = true; + } +}; + +template< class T > struct sp_if_not_array +{ + typedef boost::shared_ptr< T > type; +}; + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class T > struct sp_if_not_array< T[] > +{ +}; + +#if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) + +template< class T, std::size_t N > struct sp_if_not_array< T[N] > +{ +}; + +#endif + +#endif + +} // namespace detail + +#if !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING ) +# define BOOST_SP_MSD( T ) boost::detail::sp_inplace_tag< boost::detail::sp_ms_deleter< T > >() +#else +# define BOOST_SP_MSD( T ) boost::detail::sp_ms_deleter< T >() +#endif + +// _noinit versions + +template< class T > typename boost::detail::sp_if_not_array< T >::type make_shared_noinit() +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T; + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A > typename boost::detail::sp_if_not_array< T >::type allocate_shared_noinit( A const & a ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T; + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +#if !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + +// Variadic templates, rvalue reference + +template< class T, class... Args > typename boost::detail::sp_if_not_array< T >::type make_shared( Args && ... args ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( boost::detail::sp_forward<Args>( args )... ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class... Args > typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, Args && ... args ) +{ +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + typedef typename std::allocator_traits<A>::template rebind_alloc<T> A2; + A2 a2( a ); + + typedef boost::detail::sp_as_deleter< T, A2 > D; + + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), boost::detail::sp_inplace_tag<D>(), a2 ); + +#else + + typedef boost::detail::sp_ms_deleter< T > D; + + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), boost::detail::sp_inplace_tag<D>(), a ); + +#endif + + D * pd = static_cast< D* >( pt._internal_get_untyped_deleter() ); + void * pv = pd->address(); + +#if !defined( BOOST_NO_CXX11_ALLOCATOR ) + + std::allocator_traits<A2>::construct( a2, static_cast< T* >( pv ), boost::detail::sp_forward<Args>( args )... ); + +#else + + ::new( pv ) T( boost::detail::sp_forward<Args>( args )... ); + +#endif + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +#else // !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + +// Common zero-argument versions + +template< class T > typename boost::detail::sp_if_not_array< T >::type make_shared() +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T(); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A > typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T(); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + +// For example MSVC 10.0 + +template< class T, class A1 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2, class A3 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ), + boost::detail::sp_forward<A3>( a3 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2, class A3 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ), + boost::detail::sp_forward<A3>( a3 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2, class A3, class A4 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ), + boost::detail::sp_forward<A3>( a3 ), + boost::detail::sp_forward<A4>( a4 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2, class A3, class A4 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ), + boost::detail::sp_forward<A3>( a3 ), + boost::detail::sp_forward<A4>( a4 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2, class A3, class A4, class A5 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ), + boost::detail::sp_forward<A3>( a3 ), + boost::detail::sp_forward<A4>( a4 ), + boost::detail::sp_forward<A5>( a5 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2, class A3, class A4, class A5 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ), + boost::detail::sp_forward<A3>( a3 ), + boost::detail::sp_forward<A4>( a4 ), + boost::detail::sp_forward<A5>( a5 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2, class A3, class A4, class A5, class A6 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ), + boost::detail::sp_forward<A3>( a3 ), + boost::detail::sp_forward<A4>( a4 ), + boost::detail::sp_forward<A5>( a5 ), + boost::detail::sp_forward<A6>( a6 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ), + boost::detail::sp_forward<A3>( a3 ), + boost::detail::sp_forward<A4>( a4 ), + boost::detail::sp_forward<A5>( a5 ), + boost::detail::sp_forward<A6>( a6 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ), + boost::detail::sp_forward<A3>( a3 ), + boost::detail::sp_forward<A4>( a4 ), + boost::detail::sp_forward<A5>( a5 ), + boost::detail::sp_forward<A6>( a6 ), + boost::detail::sp_forward<A7>( a7 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ), + boost::detail::sp_forward<A3>( a3 ), + boost::detail::sp_forward<A4>( a4 ), + boost::detail::sp_forward<A5>( a5 ), + boost::detail::sp_forward<A6>( a6 ), + boost::detail::sp_forward<A7>( a7 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ), + boost::detail::sp_forward<A3>( a3 ), + boost::detail::sp_forward<A4>( a4 ), + boost::detail::sp_forward<A5>( a5 ), + boost::detail::sp_forward<A6>( a6 ), + boost::detail::sp_forward<A7>( a7 ), + boost::detail::sp_forward<A8>( a8 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ), + boost::detail::sp_forward<A3>( a3 ), + boost::detail::sp_forward<A4>( a4 ), + boost::detail::sp_forward<A5>( a5 ), + boost::detail::sp_forward<A6>( a6 ), + boost::detail::sp_forward<A7>( a7 ), + boost::detail::sp_forward<A8>( a8 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8, A9 && a9 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ), + boost::detail::sp_forward<A3>( a3 ), + boost::detail::sp_forward<A4>( a4 ), + boost::detail::sp_forward<A5>( a5 ), + boost::detail::sp_forward<A6>( a6 ), + boost::detail::sp_forward<A7>( a7 ), + boost::detail::sp_forward<A8>( a8 ), + boost::detail::sp_forward<A9>( a9 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8, A9 && a9 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( + boost::detail::sp_forward<A1>( a1 ), + boost::detail::sp_forward<A2>( a2 ), + boost::detail::sp_forward<A3>( a3 ), + boost::detail::sp_forward<A4>( a4 ), + boost::detail::sp_forward<A5>( a5 ), + boost::detail::sp_forward<A6>( a6 ), + boost::detail::sp_forward<A7>( a7 ), + boost::detail::sp_forward<A8>( a8 ), + boost::detail::sp_forward<A9>( a9 ) + ); + + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +#else // !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + +// C++03 version + +template< class T, class A1 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2, class A3 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2, A3 const & a3 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2, a3 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2, class A3 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2, a3 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2, class A3, class A4 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2, a3, a4 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2, class A3, class A4 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2, a3, a4 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2, class A3, class A4, class A5 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2, a3, a4, a5 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2, class A3, class A4, class A5 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2, a3, a4, a5 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2, class A3, class A4, class A5, class A6 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2, a3, a4, a5, a6 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2, a3, a4, a5, a6 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > +typename boost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8, A9 const & a9 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > +typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8, A9 const & a9 ) +{ + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); + + boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); + + void * pv = pd->address(); + + ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); + pd->set_initialized(); + + T * pt2 = static_cast< T* >( pv ); + + boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); + return boost::shared_ptr< T >( pt, pt2 ); +} + +#endif // !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + +#endif // !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + +#undef BOOST_SP_MSD + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_MAKE_SHARED_OBJECT_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/scoped_array.hpp b/3rdParty/Boost/src/boost/smart_ptr/scoped_array.hpp index 483460f..e395e28 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/scoped_array.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/scoped_array.hpp @@ -11,9 +11,10 @@ // http://www.boost.org/libs/smart_ptr/scoped_array.htm // +#include <boost/config.hpp> #include <boost/assert.hpp> #include <boost/checked_delete.hpp> -#include <boost/config.hpp> // in case ptrdiff_t not in std +#include <boost/smart_ptr/detail/sp_nullptr_t.hpp> #include <boost/detail/workaround.hpp> @@ -53,7 +54,7 @@ public: typedef T element_type; - explicit scoped_array( T * p = 0 ) : px( p ) // never throws + explicit scoped_array( T * p = 0 ) BOOST_NOEXCEPT : px( p ) { #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) boost::sp_array_constructor_hook( px ); @@ -68,20 +69,20 @@ public: boost::checked_array_delete( px ); } - void reset(T * p = 0) // never throws + void reset(T * p = 0) // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT) { BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors this_type(p).swap(*this); } - T & operator[](std::ptrdiff_t i) const // never throws + T & operator[](std::ptrdiff_t i) const // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT) { BOOST_ASSERT( px != 0 ); BOOST_ASSERT( i >= 0 ); return px[i]; } - T * get() const // never throws + T * get() const BOOST_NOEXCEPT { return px; } @@ -89,7 +90,7 @@ public: // implicit conversion to "bool" #include <boost/smart_ptr/detail/operator_bool.hpp> - void swap(scoped_array & b) // never throws + void swap(scoped_array & b) BOOST_NOEXCEPT { T * tmp = b.px; b.px = px; @@ -97,7 +98,31 @@ public: } }; -template<class T> inline void swap(scoped_array<T> & a, scoped_array<T> & b) // never throws +#if !defined( BOOST_NO_CXX11_NULLPTR ) + +template<class T> inline bool operator==( scoped_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +{ + return p.get() == 0; +} + +template<class T> inline bool operator==( boost::detail::sp_nullptr_t, scoped_array<T> const & p ) BOOST_NOEXCEPT +{ + return p.get() == 0; +} + +template<class T> inline bool operator!=( scoped_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +{ + return p.get() != 0; +} + +template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, scoped_array<T> const & p ) BOOST_NOEXCEPT +{ + return p.get() != 0; +} + +#endif + +template<class T> inline void swap(scoped_array<T> & a, scoped_array<T> & b) BOOST_NOEXCEPT { a.swap(b); } diff --git a/3rdParty/Boost/src/boost/smart_ptr/scoped_ptr.hpp b/3rdParty/Boost/src/boost/smart_ptr/scoped_ptr.hpp index df479e5..be6722d 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/scoped_ptr.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/scoped_ptr.hpp @@ -11,8 +11,10 @@ // http://www.boost.org/libs/smart_ptr/scoped_ptr.htm // +#include <boost/config.hpp> #include <boost/assert.hpp> #include <boost/checked_delete.hpp> +#include <boost/smart_ptr/detail/sp_nullptr_t.hpp> #include <boost/detail/workaround.hpp> #ifndef BOOST_NO_AUTO_PTR @@ -63,7 +65,7 @@ public: #ifndef BOOST_NO_AUTO_PTR - explicit scoped_ptr( std::auto_ptr<T> p ): px( p.release() ) // never throws + explicit scoped_ptr( std::auto_ptr<T> p ) BOOST_NOEXCEPT : px( p.release() ) { #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) boost::sp_scalar_constructor_hook( px ); @@ -98,7 +100,7 @@ public: return px; } - T * get() const // never throws + T * get() const BOOST_NOEXCEPT { return px; } @@ -106,7 +108,7 @@ public: // implicit conversion to "bool" #include <boost/smart_ptr/detail/operator_bool.hpp> - void swap(scoped_ptr & b) // never throws + void swap(scoped_ptr & b) BOOST_NOEXCEPT { T * tmp = b.px; b.px = px; @@ -114,14 +116,38 @@ public: } }; -template<class T> inline void swap(scoped_ptr<T> & a, scoped_ptr<T> & b) // never throws +#if !defined( BOOST_NO_CXX11_NULLPTR ) + +template<class T> inline bool operator==( scoped_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +{ + return p.get() == 0; +} + +template<class T> inline bool operator==( boost::detail::sp_nullptr_t, scoped_ptr<T> const & p ) BOOST_NOEXCEPT +{ + return p.get() == 0; +} + +template<class T> inline bool operator!=( scoped_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +{ + return p.get() != 0; +} + +template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, scoped_ptr<T> const & p ) BOOST_NOEXCEPT +{ + return p.get() != 0; +} + +#endif + +template<class T> inline void swap(scoped_ptr<T> & a, scoped_ptr<T> & b) BOOST_NOEXCEPT { a.swap(b); } // get_pointer(p) is a generic way to say p.get() -template<class T> inline T * get_pointer(scoped_ptr<T> const & p) +template<class T> inline T * get_pointer(scoped_ptr<T> const & p) BOOST_NOEXCEPT { return p.get(); } diff --git a/3rdParty/Boost/src/boost/smart_ptr/shared_array.hpp b/3rdParty/Boost/src/boost/smart_ptr/shared_array.hpp index 36799e6..fd58071 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/shared_array.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/shared_array.hpp @@ -5,7 +5,7 @@ // shared_array.hpp // // (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. -// Copyright (c) 2001, 2002 Peter Dimov +// Copyright (c) 2001, 2002, 2012 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -16,16 +16,14 @@ #include <boost/config.hpp> // for broken compiler workarounds -#if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) -#include <boost/smart_ptr/detail/shared_array_nmt.hpp> -#else - #include <memory> // TR1 cyclic inclusion fix #include <boost/assert.hpp> #include <boost/checked_delete.hpp> +#include <boost/smart_ptr/shared_ptr.hpp> #include <boost/smart_ptr/detail/shared_count.hpp> +#include <boost/smart_ptr/detail/sp_nullptr_t.hpp> #include <boost/detail/workaround.hpp> #include <cstddef> // for std::ptrdiff_t @@ -55,8 +53,22 @@ public: typedef T element_type; - explicit shared_array(T * p = 0): px(p), pn(p, deleter()) + shared_array() BOOST_NOEXCEPT : px( 0 ), pn() + { + } + +#if !defined( BOOST_NO_CXX11_NULLPTR ) + + shared_array( boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT : px( 0 ), pn() + { + } + +#endif + + template<class Y> + explicit shared_array( Y * p ): px( p ), pn( p, checked_array_deleter<Y>() ) { + boost::detail::sp_assert_convertible< Y[], T[] >(); } // @@ -65,49 +77,130 @@ public: // shared_array will release p by calling d(p) // - template<class D> shared_array(T * p, D d): px(p), pn(p, d) + template<class Y, class D> shared_array( Y * p, D d ): px( p ), pn( p, d ) + { + boost::detail::sp_assert_convertible< Y[], T[] >(); + } + + // As above, but with allocator. A's copy constructor shall not throw. + + template<class Y, class D, class A> shared_array( Y * p, D d, A a ): px( p ), pn( p, d, a ) { + boost::detail::sp_assert_convertible< Y[], T[] >(); } // generated copy constructor, destructor are fine... -#if defined( BOOST_HAS_RVALUE_REFS ) +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) // ... except in C++0x, move disables the implicit copy - shared_array( shared_array const & r ): px( r.px ), pn( r.pn ) // never throws + shared_array( shared_array const & r ) BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) { } + shared_array( shared_array && r ) BOOST_NOEXCEPT : px( r.px ), pn() + { + pn.swap( r.pn ); + r.px = 0; + } + #endif + // conversion + + template<class Y> +#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) + + shared_array( shared_array<Y> const & r, typename boost::detail::sp_enable_if_convertible< Y[], T[] >::type = boost::detail::sp_empty() ) + +#else + + shared_array( shared_array<Y> const & r ) + +#endif + BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) // never throws + { + boost::detail::sp_assert_convertible< Y[], T[] >(); + } + + // aliasing + + template< class Y > + shared_array( shared_array<Y> const & r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn ) + { + } + // assignment - shared_array & operator=( shared_array const & r ) // never throws + shared_array & operator=( shared_array const & r ) BOOST_NOEXCEPT { this_type( r ).swap( *this ); return *this; } - void reset(T * p = 0) +#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1400) + + template<class Y> + shared_array & operator=( shared_array<Y> const & r ) BOOST_NOEXCEPT { - BOOST_ASSERT(p == 0 || p != px); - this_type(p).swap(*this); + this_type( r ).swap( *this ); + return *this; } - template <class D> void reset(T * p, D d) +#endif + +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + + shared_array & operator=( shared_array && r ) BOOST_NOEXCEPT { - this_type(p, d).swap(*this); + this_type( static_cast< shared_array && >( r ) ).swap( *this ); + return *this; } - T & operator[] (std::ptrdiff_t i) const // never throws + template<class Y> + shared_array & operator=( shared_array<Y> && r ) BOOST_NOEXCEPT + { + this_type( static_cast< shared_array<Y> && >( r ) ).swap( *this ); + return *this; + } + +#endif + + void reset() BOOST_NOEXCEPT + { + this_type().swap( *this ); + } + + template<class Y> void reset( Y * p ) // Y must be complete + { + BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors + this_type( p ).swap( *this ); + } + + template<class Y, class D> void reset( Y * p, D d ) + { + this_type( p, d ).swap( *this ); + } + + template<class Y, class D, class A> void reset( Y * p, D d, A a ) + { + this_type( p, d, a ).swap( *this ); + } + + template<class Y> void reset( shared_array<Y> const & r, element_type * p ) + { + this_type( r, p ).swap( *this ); + } + + T & operator[] (std::ptrdiff_t i) const // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT) { BOOST_ASSERT(px != 0); BOOST_ASSERT(i >= 0); return px[i]; } - T * get() const // never throws + T * get() const BOOST_NOEXCEPT { return px; } @@ -115,17 +208,17 @@ public: // implicit conversion to "bool" #include <boost/smart_ptr/detail/operator_bool.hpp> - bool unique() const // never throws + bool unique() const BOOST_NOEXCEPT { return pn.unique(); } - long use_count() const // never throws + long use_count() const BOOST_NOEXCEPT { return pn.use_count(); } - void swap(shared_array<T> & other) // never throws + void swap(shared_array<T> & other) BOOST_NOEXCEPT { std::swap(px, other.px); pn.swap(other.pn); @@ -138,27 +231,53 @@ public: private: + template<class Y> friend class shared_array; + T * px; // contained pointer detail::shared_count pn; // reference counter }; // shared_array -template<class T> inline bool operator==(shared_array<T> const & a, shared_array<T> const & b) // never throws +template<class T> inline bool operator==(shared_array<T> const & a, shared_array<T> const & b) BOOST_NOEXCEPT { return a.get() == b.get(); } -template<class T> inline bool operator!=(shared_array<T> const & a, shared_array<T> const & b) // never throws +template<class T> inline bool operator!=(shared_array<T> const & a, shared_array<T> const & b) BOOST_NOEXCEPT { return a.get() != b.get(); } -template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) // never throws +#if !defined( BOOST_NO_CXX11_NULLPTR ) + +template<class T> inline bool operator==( shared_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +{ + return p.get() == 0; +} + +template<class T> inline bool operator==( boost::detail::sp_nullptr_t, shared_array<T> const & p ) BOOST_NOEXCEPT +{ + return p.get() == 0; +} + +template<class T> inline bool operator!=( shared_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT +{ + return p.get() != 0; +} + +template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, shared_array<T> const & p ) BOOST_NOEXCEPT +{ + return p.get() != 0; +} + +#endif + +template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) BOOST_NOEXCEPT { return std::less<T*>()(a.get(), b.get()); } -template<class T> void swap(shared_array<T> & a, shared_array<T> & b) // never throws +template<class T> void swap(shared_array<T> & a, shared_array<T> & b) BOOST_NOEXCEPT { a.swap(b); } @@ -170,6 +289,4 @@ template< class D, class T > D * get_deleter( shared_array<T> const & p ) } // namespace boost -#endif // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) - #endif // #ifndef BOOST_SMART_PTR_SHARED_ARRAY_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/shared_ptr.hpp b/3rdParty/Boost/src/boost/smart_ptr/shared_ptr.hpp index 1bfb75c..83b0451 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/shared_ptr.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/shared_ptr.hpp @@ -16,10 +16,6 @@ #include <boost/config.hpp> // for broken compiler workarounds -#if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) -#include <boost/smart_ptr/detail/shared_ptr_nmt.hpp> -#else - // In order to avoid circular dependencies with Boost.TR1 // we make sure that our include of <memory> doesn't try to // pull in the TR1 headers: that's why we use this header @@ -32,10 +28,10 @@ #include <boost/smart_ptr/detail/shared_count.hpp> #include <boost/detail/workaround.hpp> #include <boost/smart_ptr/detail/sp_convertible.hpp> +#include <boost/smart_ptr/detail/sp_nullptr_t.hpp> #if !defined(BOOST_SP_NO_ATOMIC_ACCESS) #include <boost/smart_ptr/detail/spinlock_pool.hpp> -#include <boost/memory_order.hpp> #endif #include <algorithm> // for std::swap @@ -57,45 +53,151 @@ namespace boost template<class T> class shared_ptr; template<class T> class weak_ptr; template<class T> class enable_shared_from_this; -template<class T> class enable_shared_from_this2; +class enable_shared_from_raw; namespace detail { -struct static_cast_tag {}; -struct const_cast_tag {}; -struct dynamic_cast_tag {}; -struct polymorphic_cast_tag {}; +// sp_element, element_type + +template< class T > struct sp_element +{ + typedef T type; +}; + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class T > struct sp_element< T[] > +{ + typedef T type; +}; + +#if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) -template<class T> struct shared_ptr_traits +template< class T, std::size_t N > struct sp_element< T[N] > { - typedef T & reference; + typedef T type; }; -template<> struct shared_ptr_traits<void> +#endif + +#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +// sp_dereference, return type of operator* + +template< class T > struct sp_dereference { - typedef void reference; + typedef T & type; +}; + +template<> struct sp_dereference< void > +{ + typedef void type; }; #if !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS) -template<> struct shared_ptr_traits<void const> +template<> struct sp_dereference< void const > +{ + typedef void type; +}; + +template<> struct sp_dereference< void volatile > { - typedef void reference; + typedef void type; }; -template<> struct shared_ptr_traits<void volatile> +template<> struct sp_dereference< void const volatile > { - typedef void reference; + typedef void type; }; -template<> struct shared_ptr_traits<void const volatile> +#endif // !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS) + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class T > struct sp_dereference< T[] > { - typedef void reference; + typedef void type; +}; + +#if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) + +template< class T, std::size_t N > struct sp_dereference< T[N] > +{ + typedef void type; }; #endif +#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +// sp_member_access, return type of operator-> + +template< class T > struct sp_member_access +{ + typedef T * type; +}; + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class T > struct sp_member_access< T[] > +{ + typedef void type; +}; + +#if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) + +template< class T, std::size_t N > struct sp_member_access< T[N] > +{ + typedef void type; +}; + +#endif + +#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +// sp_array_access, return type of operator[] + +template< class T > struct sp_array_access +{ + typedef void type; +}; + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class T > struct sp_array_access< T[] > +{ + typedef T & type; +}; + +#if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) + +template< class T, std::size_t N > struct sp_array_access< T[N] > +{ + typedef T & type; +}; + +#endif + +#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +// sp_extent, for operator[] index check + +template< class T > struct sp_extent +{ + enum _vt { value = 0 }; +}; + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class T, std::size_t N > struct sp_extent< T[N] > +{ + enum _vt { value = N }; +}; + +#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + // enable_shared_from_this support template< class X, class Y, class T > inline void sp_enable_shared_from_this( boost::shared_ptr<X> const * ppx, Y const * py, boost::enable_shared_from_this< T > const * pe ) @@ -106,13 +208,7 @@ template< class X, class Y, class T > inline void sp_enable_shared_from_this( bo } } -template< class X, class Y, class T > inline void sp_enable_shared_from_this( boost::shared_ptr<X> * ppx, Y const * py, boost::enable_shared_from_this2< T > const * pe ) -{ - if( pe != 0 ) - { - pe->_internal_accept_owner( ppx, const_cast< Y* >( py ) ); - } -} +template< class X, class Y > inline void sp_enable_shared_from_this( boost::shared_ptr<X> * ppx, Y const * py, boost::enable_shared_from_raw const * pe ); #ifdef _MANAGED @@ -150,6 +246,69 @@ template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R #endif +// sp_assert_convertible + +template< class Y, class T > inline void sp_assert_convertible() +{ +#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) + + // static_assert( sp_convertible< Y, T >::value ); + typedef char tmp[ sp_convertible< Y, T >::value? 1: -1 ]; + (void)sizeof( tmp ); + +#else + + T* p = static_cast< Y* >( 0 ); + (void)p; + +#endif +} + +// pointer constructor helper + +template< class T, class Y > inline void sp_pointer_construct( boost::shared_ptr< T > * ppx, Y * p, boost::detail::shared_count & pn ) +{ + boost::detail::shared_count( p ).swap( pn ); + boost::detail::sp_enable_shared_from_this( ppx, p, p ); +} + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class T, class Y > inline void sp_pointer_construct( boost::shared_ptr< T[] > * /*ppx*/, Y * p, boost::detail::shared_count & pn ) +{ + sp_assert_convertible< Y[], T[] >(); + boost::detail::shared_count( p, boost::checked_array_deleter< T >() ).swap( pn ); +} + +template< class T, std::size_t N, class Y > inline void sp_pointer_construct( boost::shared_ptr< T[N] > * /*ppx*/, Y * p, boost::detail::shared_count & pn ) +{ + sp_assert_convertible< Y[N], T[N] >(); + boost::detail::shared_count( p, boost::checked_array_deleter< T >() ).swap( pn ); +} + +#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +// deleter constructor helper + +template< class T, class Y > inline void sp_deleter_construct( boost::shared_ptr< T > * ppx, Y * p ) +{ + boost::detail::sp_enable_shared_from_this( ppx, p, p ); +} + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class T, class Y > inline void sp_deleter_construct( boost::shared_ptr< T[] > * /*ppx*/, Y * /*p*/ ) +{ + sp_assert_convertible< Y[], T[] >(); +} + +template< class T, std::size_t N, class Y > inline void sp_deleter_construct( boost::shared_ptr< T[N] > * /*ppx*/, Y * /*p*/ ) +{ + sp_assert_convertible< Y[N], T[N] >(); +} + +#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + } // namespace detail @@ -170,19 +329,24 @@ private: public: - typedef T element_type; - typedef T value_type; - typedef T * pointer; - typedef typename boost::detail::shared_ptr_traits<T>::reference reference; + typedef typename boost::detail::sp_element< T >::type element_type; + + shared_ptr() BOOST_NOEXCEPT : px( 0 ), pn() // never throws in 1.30+ + { + } + +#if !defined( BOOST_NO_CXX11_NULLPTR ) - shared_ptr(): px(0), pn() // never throws in 1.30+ + shared_ptr( boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT : px( 0 ), pn() // never throws { } +#endif + template<class Y> - explicit shared_ptr( Y * p ): px( p ), pn( p ) // Y must be complete + explicit shared_ptr( Y * p ): px( p ), pn() // Y must be complete { - boost::detail::sp_enable_shared_from_this( this, p, p ); + boost::detail::sp_pointer_construct( this, p, pn ); } // @@ -191,39 +355,58 @@ public: // shared_ptr will release p by calling d(p) // - template<class Y, class D> shared_ptr(Y * p, D d): px(p), pn(p, d) + template<class Y, class D> shared_ptr( Y * p, D d ): px( p ), pn( p, d ) { - boost::detail::sp_enable_shared_from_this( this, p, p ); + boost::detail::sp_deleter_construct( this, p ); } +#if !defined( BOOST_NO_CXX11_NULLPTR ) + + template<class D> shared_ptr( boost::detail::sp_nullptr_t p, D d ): px( p ), pn( p, d ) + { + } + +#endif + // As above, but with allocator. A's copy constructor shall not throw. template<class Y, class D, class A> shared_ptr( Y * p, D d, A a ): px( p ), pn( p, d, a ) { - boost::detail::sp_enable_shared_from_this( this, p, p ); + boost::detail::sp_deleter_construct( this, p ); + } + +#if !defined( BOOST_NO_CXX11_NULLPTR ) + + template<class D, class A> shared_ptr( boost::detail::sp_nullptr_t p, D d, A a ): px( p ), pn( p, d, a ) + { } +#endif + // generated copy constructor, destructor are fine... -#if defined( BOOST_HAS_RVALUE_REFS ) +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) // ... except in C++0x, move disables the implicit copy - shared_ptr( shared_ptr const & r ): px( r.px ), pn( r.pn ) // never throws + shared_ptr( shared_ptr const & r ) BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) { } #endif template<class Y> - explicit shared_ptr(weak_ptr<Y> const & r): pn(r.pn) // may throw + explicit shared_ptr( weak_ptr<Y> const & r ): pn( r.pn ) // may throw { + boost::detail::sp_assert_convertible< Y, T >(); + // it is now safe to copy r.px, as pn(r.pn) did not throw px = r.px; } template<class Y> - shared_ptr( weak_ptr<Y> const & r, boost::detail::sp_nothrow_tag ): px( 0 ), pn( r.pn, boost::detail::sp_nothrow_tag() ) // never throws + shared_ptr( weak_ptr<Y> const & r, boost::detail::sp_nothrow_tag ) + BOOST_NOEXCEPT : px( 0 ), pn( r.pn, boost::detail::sp_nothrow_tag() ) { if( !pn.empty() ) { @@ -241,72 +424,80 @@ public: shared_ptr( shared_ptr<Y> const & r ) #endif - : px( r.px ), pn( r.pn ) // never throws + BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) { + boost::detail::sp_assert_convertible< Y, T >(); } // aliasing template< class Y > - shared_ptr( shared_ptr<Y> const & r, T * p ): px( p ), pn( r.pn ) // never throws + shared_ptr( shared_ptr<Y> const & r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn ) { } - template<class Y> - shared_ptr(shared_ptr<Y> const & r, boost::detail::static_cast_tag): px(static_cast<element_type *>(r.px)), pn(r.pn) - { - } +#ifndef BOOST_NO_AUTO_PTR template<class Y> - shared_ptr(shared_ptr<Y> const & r, boost::detail::const_cast_tag): px(const_cast<element_type *>(r.px)), pn(r.pn) + explicit shared_ptr( std::auto_ptr<Y> & r ): px(r.get()), pn() { - } + boost::detail::sp_assert_convertible< Y, T >(); - template<class Y> - shared_ptr(shared_ptr<Y> const & r, boost::detail::dynamic_cast_tag): px(dynamic_cast<element_type *>(r.px)), pn(r.pn) - { - if(px == 0) // need to allocate new counter -- the cast failed - { - pn = boost::detail::shared_count(); - } - } + Y * tmp = r.get(); + pn = boost::detail::shared_count( r ); - template<class Y> - shared_ptr(shared_ptr<Y> const & r, boost::detail::polymorphic_cast_tag): px(dynamic_cast<element_type *>(r.px)), pn(r.pn) - { - if(px == 0) - { - boost::throw_exception(std::bad_cast()); - } + boost::detail::sp_deleter_construct( this, tmp ); } -#ifndef BOOST_NO_AUTO_PTR +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) template<class Y> - explicit shared_ptr(std::auto_ptr<Y> & r): px(r.get()), pn() + shared_ptr( std::auto_ptr<Y> && r ): px(r.get()), pn() { + boost::detail::sp_assert_convertible< Y, T >(); + Y * tmp = r.get(); - pn = boost::detail::shared_count(r); - boost::detail::sp_enable_shared_from_this( this, tmp, tmp ); + pn = boost::detail::shared_count( r ); + + boost::detail::sp_deleter_construct( this, tmp ); } -#if !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) +#elif !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template<class Ap> explicit shared_ptr( Ap r, typename boost::detail::sp_enable_if_auto_ptr<Ap, int>::type = 0 ): px( r.get() ), pn() { - typename Ap::element_type * tmp = r.get(); + typedef typename Ap::element_type Y; + + boost::detail::sp_assert_convertible< Y, T >(); + + Y * tmp = r.get(); pn = boost::detail::shared_count( r ); - boost::detail::sp_enable_shared_from_this( this, tmp, tmp ); - } + boost::detail::sp_deleter_construct( this, tmp ); + } #endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION #endif // BOOST_NO_AUTO_PTR +#if !defined( BOOST_NO_CXX11_SMART_PTR ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + + template< class Y, class D > + shared_ptr( std::unique_ptr< Y, D > && r ): px( r.get() ), pn() + { + boost::detail::sp_assert_convertible< Y, T >(); + + typename std::unique_ptr< Y, D >::pointer tmp = r.get(); + pn = boost::detail::shared_count( r ); + + boost::detail::sp_deleter_construct( this, tmp ); + } + +#endif + // assignment - shared_ptr & operator=( shared_ptr const & r ) // never throws + shared_ptr & operator=( shared_ptr const & r ) BOOST_NOEXCEPT { this_type(r).swap(*this); return *this; @@ -315,7 +506,7 @@ public: #if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1400) template<class Y> - shared_ptr & operator=(shared_ptr<Y> const & r) // never throws + shared_ptr & operator=(shared_ptr<Y> const & r) BOOST_NOEXCEPT { this_type(r).swap(*this); return *this; @@ -328,11 +519,20 @@ public: template<class Y> shared_ptr & operator=( std::auto_ptr<Y> & r ) { - this_type(r).swap(*this); + this_type( r ).swap( *this ); + return *this; + } + +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + + template<class Y> + shared_ptr & operator=( std::auto_ptr<Y> && r ) + { + this_type( static_cast< std::auto_ptr<Y> && >( r ) ).swap( *this ); return *this; } -#if !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) +#elif !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template<class Ap> typename boost::detail::sp_enable_if_auto_ptr< Ap, shared_ptr & >::type operator=( Ap r ) @@ -341,16 +541,26 @@ public: return *this; } - #endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION #endif // BOOST_NO_AUTO_PTR +#if !defined( BOOST_NO_CXX11_SMART_PTR ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + + template<class Y, class D> + shared_ptr & operator=( std::unique_ptr<Y, D> && r ) + { + this_type( static_cast< std::unique_ptr<Y, D> && >( r ) ).swap(*this); + return *this; + } + +#endif + // Move support -#if defined( BOOST_HAS_RVALUE_REFS ) +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) - shared_ptr( shared_ptr && r ): px( r.px ), pn() // never throws + shared_ptr( shared_ptr && r ) BOOST_NOEXCEPT : px( r.px ), pn() { pn.swap( r.pn ); r.px = 0; @@ -366,20 +576,22 @@ public: shared_ptr( shared_ptr<Y> && r ) #endif - : px( r.px ), pn() // never throws + BOOST_NOEXCEPT : px( r.px ), pn() { + boost::detail::sp_assert_convertible< Y, T >(); + pn.swap( r.pn ); r.px = 0; } - shared_ptr & operator=( shared_ptr && r ) // never throws + shared_ptr & operator=( shared_ptr && r ) BOOST_NOEXCEPT { this_type( static_cast< shared_ptr && >( r ) ).swap( *this ); return *this; } template<class Y> - shared_ptr & operator=( shared_ptr<Y> && r ) // never throws + shared_ptr & operator=( shared_ptr<Y> && r ) BOOST_NOEXCEPT { this_type( static_cast< shared_ptr<Y> && >( r ) ).swap( *this ); return *this; @@ -387,15 +599,25 @@ public: #endif - void reset() // never throws in 1.30+ +#if !defined( BOOST_NO_CXX11_NULLPTR ) + + shared_ptr & operator=( boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT // never throws { this_type().swap(*this); + return *this; } - template<class Y> void reset(Y * p) // Y must be complete +#endif + + void reset() BOOST_NOEXCEPT // never throws in 1.30+ { - BOOST_ASSERT(p == 0 || p != px); // catch self-reset errors - this_type(p).swap(*this); + this_type().swap(*this); + } + + template<class Y> void reset( Y * p ) // Y must be complete + { + BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors + this_type( p ).swap( *this ); } template<class Y, class D> void reset( Y * p, D d ) @@ -408,24 +630,35 @@ public: this_type( p, d, a ).swap( *this ); } - template<class Y> void reset( shared_ptr<Y> const & r, T * p ) + template<class Y> void reset( shared_ptr<Y> const & r, element_type * p ) { this_type( r, p ).swap( *this ); } - - reference operator* () const // never throws + + // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT) + typename boost::detail::sp_dereference< T >::type operator* () const { - BOOST_ASSERT(px != 0); + BOOST_ASSERT( px != 0 ); return *px; } - - T * operator-> () const // never throws + + // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT) + typename boost::detail::sp_member_access< T >::type operator-> () const { - BOOST_ASSERT(px != 0); + BOOST_ASSERT( px != 0 ); return px; } + + // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT) + typename boost::detail::sp_array_access< T >::type operator[] ( std::ptrdiff_t i ) const + { + BOOST_ASSERT( px != 0 ); + BOOST_ASSERT( i >= 0 && ( i < boost::detail::sp_extent< T >::value || boost::detail::sp_extent< T >::value == 0 ) ); + + return px[ i ]; + } - T * get() const // never throws + element_type * get() const BOOST_NOEXCEPT { return px; } @@ -433,38 +666,43 @@ public: // implicit conversion to "bool" #include <boost/smart_ptr/detail/operator_bool.hpp> - bool unique() const // never throws + bool unique() const BOOST_NOEXCEPT { return pn.unique(); } - long use_count() const // never throws + long use_count() const BOOST_NOEXCEPT { return pn.use_count(); } - void swap(shared_ptr<T> & other) // never throws + void swap( shared_ptr & other ) BOOST_NOEXCEPT { std::swap(px, other.px); pn.swap(other.pn); } - template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const + template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const BOOST_NOEXCEPT { return pn < rhs.pn; } - template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const + template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const BOOST_NOEXCEPT { return pn < rhs.pn; } - void * _internal_get_deleter( boost::detail::sp_typeinfo const & ti ) const + void * _internal_get_deleter( boost::detail::sp_typeinfo const & ti ) const BOOST_NOEXCEPT { return pn.get_deleter( ti ); } - bool _internal_equiv( shared_ptr const & r ) const + void * _internal_get_untyped_deleter() const BOOST_NOEXCEPT + { + return pn.get_untyped_deleter(); + } + + bool _internal_equiv( shared_ptr const & r ) const BOOST_NOEXCEPT { return px == r.px && pn == r.pn; } @@ -482,17 +720,17 @@ private: #endif - T * px; // contained pointer + element_type * px; // contained pointer boost::detail::shared_count pn; // reference counter }; // shared_ptr -template<class T, class U> inline bool operator==(shared_ptr<T> const & a, shared_ptr<U> const & b) +template<class T, class U> inline bool operator==(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT { return a.get() == b.get(); } -template<class T, class U> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<U> const & b) +template<class T, class U> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT { return a.get() != b.get(); } @@ -501,64 +739,90 @@ template<class T, class U> inline bool operator!=(shared_ptr<T> const & a, share // Resolve the ambiguity between our op!= and the one in rel_ops -template<class T> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<T> const & b) +template<class T> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<T> const & b) BOOST_NOEXCEPT { return a.get() != b.get(); } #endif -template<class T, class U> inline bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b) +#if !defined( BOOST_NO_CXX11_NULLPTR ) + +template<class T> inline bool operator==( shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT { - return a.owner_before( b ); + return p.get() == 0; } -template<class T> inline void swap(shared_ptr<T> & a, shared_ptr<T> & b) +template<class T> inline bool operator==( boost::detail::sp_nullptr_t, shared_ptr<T> const & p ) BOOST_NOEXCEPT { - a.swap(b); + return p.get() == 0; } -template<class T, class U> shared_ptr<T> static_pointer_cast(shared_ptr<U> const & r) +template<class T> inline bool operator!=( shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT { - return shared_ptr<T>(r, boost::detail::static_cast_tag()); + return p.get() != 0; } -template<class T, class U> shared_ptr<T> const_pointer_cast(shared_ptr<U> const & r) +template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, shared_ptr<T> const & p ) BOOST_NOEXCEPT { - return shared_ptr<T>(r, boost::detail::const_cast_tag()); + return p.get() != 0; } -template<class T, class U> shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const & r) +#endif + +template<class T, class U> inline bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT { - return shared_ptr<T>(r, boost::detail::dynamic_cast_tag()); + return a.owner_before( b ); } -// shared_*_cast names are deprecated. Use *_pointer_cast instead. +template<class T> inline void swap(shared_ptr<T> & a, shared_ptr<T> & b) BOOST_NOEXCEPT +{ + a.swap(b); +} -template<class T, class U> shared_ptr<T> shared_static_cast(shared_ptr<U> const & r) +template<class T, class U> shared_ptr<T> static_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT { - return shared_ptr<T>(r, boost::detail::static_cast_tag()); + (void) static_cast< T* >( static_cast< U* >( 0 ) ); + + typedef typename shared_ptr<T>::element_type E; + + E * p = static_cast< E* >( r.get() ); + return shared_ptr<T>( r, p ); } -template<class T, class U> shared_ptr<T> shared_dynamic_cast(shared_ptr<U> const & r) +template<class T, class U> shared_ptr<T> const_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT { - return shared_ptr<T>(r, boost::detail::dynamic_cast_tag()); + (void) const_cast< T* >( static_cast< U* >( 0 ) ); + + typedef typename shared_ptr<T>::element_type E; + + E * p = const_cast< E* >( r.get() ); + return shared_ptr<T>( r, p ); } -template<class T, class U> shared_ptr<T> shared_polymorphic_cast(shared_ptr<U> const & r) +template<class T, class U> shared_ptr<T> dynamic_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT { - return shared_ptr<T>(r, boost::detail::polymorphic_cast_tag()); + (void) dynamic_cast< T* >( static_cast< U* >( 0 ) ); + + typedef typename shared_ptr<T>::element_type E; + + E * p = dynamic_cast< E* >( r.get() ); + return p? shared_ptr<T>( r, p ): shared_ptr<T>(); } -template<class T, class U> shared_ptr<T> shared_polymorphic_downcast(shared_ptr<U> const & r) +template<class T, class U> shared_ptr<T> reinterpret_pointer_cast( shared_ptr<U> const & r ) BOOST_NOEXCEPT { - BOOST_ASSERT(dynamic_cast<T *>(r.get()) == r.get()); - return shared_static_cast<T>(r); + (void) reinterpret_cast< T* >( static_cast< U* >( 0 ) ); + + typedef typename shared_ptr<T>::element_type E; + + E * p = reinterpret_cast< E* >( r.get() ); + return shared_ptr<T>( r, p ); } // get_pointer() enables boost::mem_fn to recognize shared_ptr -template<class T> inline T * get_pointer(shared_ptr<T> const & p) +template<class T> inline typename shared_ptr<T>::element_type * get_pointer(shared_ptr<T> const & p) BOOST_NOEXCEPT { return p.get(); } @@ -600,6 +864,9 @@ template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std:: // get_deleter +namespace detail +{ + #if ( defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3) ) || \ ( defined(__EDG_VERSION__) && BOOST_WORKAROUND(__EDG_VERSION__, <= 238) ) || \ ( defined(__HP_aCC) && BOOST_WORKAROUND(__HP_aCC, <= 33500) ) @@ -607,7 +874,7 @@ template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std:: // g++ 2.9x doesn't allow static_cast<X const *>(void *) // apparently EDG 2.38 and HP aCC A.03.35 also don't accept it -template<class D, class T> D * get_deleter(shared_ptr<T> const & p) +template<class D, class T> D * basic_get_deleter(shared_ptr<T> const & p) { void const * q = p._internal_get_deleter(BOOST_SP_TYPEID(D)); return const_cast<D *>(static_cast<D const *>(q)); @@ -615,18 +882,64 @@ template<class D, class T> D * get_deleter(shared_ptr<T> const & p) #else -template<class D, class T> D * get_deleter(shared_ptr<T> const & p) +template<class D, class T> D * basic_get_deleter( shared_ptr<T> const & p ) BOOST_NOEXCEPT { - return static_cast<D *>(p._internal_get_deleter(BOOST_SP_TYPEID(D))); + return static_cast<D *>( p._internal_get_deleter(BOOST_SP_TYPEID(D)) ); } #endif +class esft2_deleter_wrapper +{ +private: + + shared_ptr<void> deleter_; + +public: + + esft2_deleter_wrapper() + { + } + + template< class T > void set_deleter( shared_ptr<T> const & deleter ) + { + deleter_ = deleter; + } + + template<typename D> D* get_deleter() const BOOST_NOEXCEPT + { + return boost::detail::basic_get_deleter<D>( deleter_ ); + } + + template< class T> void operator()( T* ) + { + BOOST_ASSERT( deleter_.use_count() <= 1 ); + deleter_.reset(); + } +}; + +} // namespace detail + +template<class D, class T> D * get_deleter( shared_ptr<T> const & p ) BOOST_NOEXCEPT +{ + D *del = boost::detail::basic_get_deleter<D>(p); + + if(del == 0) + { + boost::detail::esft2_deleter_wrapper *del_wrapper = boost::detail::basic_get_deleter<boost::detail::esft2_deleter_wrapper>(p); +// The following get_deleter method call is fully qualified because +// older versions of gcc (2.95, 3.2.3) fail to compile it when written del_wrapper->get_deleter<D>() + if(del_wrapper) del = del_wrapper->::boost::detail::esft2_deleter_wrapper::get_deleter<D>(); + } + + return del; +} + // atomic access #if !defined(BOOST_SP_NO_ATOMIC_ACCESS) -template<class T> inline bool atomic_is_lock_free( shared_ptr<T> const * /*p*/ ) +template<class T> inline bool atomic_is_lock_free( shared_ptr<T> const * /*p*/ ) BOOST_NOEXCEPT { return false; } @@ -637,7 +950,7 @@ template<class T> shared_ptr<T> atomic_load( shared_ptr<T> const * p ) return *p; } -template<class T> inline shared_ptr<T> atomic_load_explicit( shared_ptr<T> const * p, memory_order /*mo*/ ) +template<class T> inline shared_ptr<T> atomic_load_explicit( shared_ptr<T> const * p, /*memory_order mo*/ int ) { return atomic_load( p ); } @@ -648,7 +961,7 @@ template<class T> void atomic_store( shared_ptr<T> * p, shared_ptr<T> r ) p->swap( r ); } -template<class T> inline void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, memory_order /*mo*/ ) +template<class T> inline void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int ) { atomic_store( p, r ); // std::move( r ) } @@ -664,7 +977,7 @@ template<class T> shared_ptr<T> atomic_exchange( shared_ptr<T> * p, shared_ptr<T return r; // return std::move( r ) } -template<class T> shared_ptr<T> atomic_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> r, memory_order /*mo*/ ) +template<class T> shared_ptr<T> atomic_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int ) { return atomic_exchange( p, r ); // std::move( r ) } @@ -694,7 +1007,7 @@ template<class T> bool atomic_compare_exchange( shared_ptr<T> * p, shared_ptr<T> } } -template<class T> inline bool atomic_compare_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, memory_order /*success*/, memory_order /*failure*/ ) +template<class T> inline bool atomic_compare_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, /*memory_order success*/ int, /*memory_order failure*/ int ) { return atomic_compare_exchange( p, v, w ); // std::move( w ) } @@ -705,13 +1018,11 @@ template<class T> inline bool atomic_compare_exchange_explicit( shared_ptr<T> * template< class T > struct hash; -template< class T > std::size_t hash_value( boost::shared_ptr<T> const & p ) +template< class T > std::size_t hash_value( boost::shared_ptr<T> const & p ) BOOST_NOEXCEPT { return boost::hash< T* >()( p.get() ); } } // namespace boost -#endif // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) - #endif // #ifndef BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED diff --git a/3rdParty/Boost/src/boost/smart_ptr/weak_ptr.hpp b/3rdParty/Boost/src/boost/smart_ptr/weak_ptr.hpp index 2e35583..e3e9ad9 100644 --- a/3rdParty/Boost/src/boost/smart_ptr/weak_ptr.hpp +++ b/3rdParty/Boost/src/boost/smart_ptr/weak_ptr.hpp @@ -29,23 +29,23 @@ private: public: - typedef T element_type; + typedef typename boost::detail::sp_element< T >::type element_type; - weak_ptr(): px(0), pn() // never throws in 1.30+ + weak_ptr() BOOST_NOEXCEPT : px(0), pn() // never throws in 1.30+ { } // generated copy constructor, assignment, destructor are fine... -#if defined( BOOST_HAS_RVALUE_REFS ) +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) // ... except in C++0x, move disables the implicit copy - weak_ptr( weak_ptr const & r ): px( r.px ), pn( r.pn ) // never throws + weak_ptr( weak_ptr const & r ) BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) { } - weak_ptr & operator=( weak_ptr const & r ) // never throws + weak_ptr & operator=( weak_ptr const & r ) BOOST_NOEXCEPT { px = r.px; pn = r.pn; @@ -81,11 +81,12 @@ public: weak_ptr( weak_ptr<Y> const & r ) #endif - : px(r.lock().get()), pn(r.pn) // never throws + BOOST_NOEXCEPT : px(r.lock().get()), pn(r.pn) { + boost::detail::sp_assert_convertible< Y, T >(); } -#if defined( BOOST_HAS_RVALUE_REFS ) +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) template<class Y> #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) @@ -97,19 +98,21 @@ public: weak_ptr( weak_ptr<Y> && r ) #endif - : px( r.lock().get() ), pn( static_cast< boost::detail::weak_count && >( r.pn ) ) // never throws + BOOST_NOEXCEPT : px( r.lock().get() ), pn( static_cast< boost::detail::weak_count && >( r.pn ) ) { + boost::detail::sp_assert_convertible< Y, T >(); r.px = 0; } // for better efficiency in the T == Y case - weak_ptr( weak_ptr && r ): px( r.px ), pn( static_cast< boost::detail::weak_count && >( r.pn ) ) // never throws + weak_ptr( weak_ptr && r ) + BOOST_NOEXCEPT : px( r.px ), pn( static_cast< boost::detail::weak_count && >( r.pn ) ) { r.px = 0; } // for better efficiency in the T == Y case - weak_ptr & operator=( weak_ptr && r ) // never throws + weak_ptr & operator=( weak_ptr && r ) BOOST_NOEXCEPT { this_type( static_cast< weak_ptr && >( r ) ).swap( *this ); return *this; @@ -128,24 +131,28 @@ public: weak_ptr( shared_ptr<Y> const & r ) #endif - : px( r.px ), pn( r.pn ) // never throws + BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) { + boost::detail::sp_assert_convertible< Y, T >(); } #if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300) template<class Y> - weak_ptr & operator=(weak_ptr<Y> const & r) // never throws + weak_ptr & operator=( weak_ptr<Y> const & r ) BOOST_NOEXCEPT { + boost::detail::sp_assert_convertible< Y, T >(); + px = r.lock().get(); pn = r.pn; + return *this; } -#if defined( BOOST_HAS_RVALUE_REFS ) +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) template<class Y> - weak_ptr & operator=( weak_ptr<Y> && r ) + weak_ptr & operator=( weak_ptr<Y> && r ) BOOST_NOEXCEPT { this_type( static_cast< weak_ptr<Y> && >( r ) ).swap( *this ); return *this; @@ -154,26 +161,29 @@ public: #endif template<class Y> - weak_ptr & operator=(shared_ptr<Y> const & r) // never throws + weak_ptr & operator=( shared_ptr<Y> const & r ) BOOST_NOEXCEPT { + boost::detail::sp_assert_convertible< Y, T >(); + px = r.px; pn = r.pn; + return *this; } #endif - shared_ptr<T> lock() const // never throws + shared_ptr<T> lock() const BOOST_NOEXCEPT { - return shared_ptr<element_type>( *this, boost::detail::sp_nothrow_tag() ); + return shared_ptr<T>( *this, boost::detail::sp_nothrow_tag() ); } - long use_count() const // never throws + long use_count() const BOOST_NOEXCEPT { return pn.use_count(); } - bool expired() const // never throws + bool expired() const BOOST_NOEXCEPT { return pn.use_count() == 0; } @@ -183,29 +193,30 @@ public: return pn.empty(); } - void reset() // never throws in 1.30+ + void reset() BOOST_NOEXCEPT // never throws in 1.30+ { this_type().swap(*this); } - void swap(this_type & other) // never throws + void swap(this_type & other) BOOST_NOEXCEPT { std::swap(px, other.px); pn.swap(other.pn); } - void _internal_assign(T * px2, boost::detail::shared_count const & pn2) + template<typename Y> + void _internal_aliasing_assign(weak_ptr<Y> const & r, element_type * px2) { px = px2; - pn = pn2; + pn = r.pn; } - template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const + template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const BOOST_NOEXCEPT { return pn < rhs.pn; } - template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const + template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const BOOST_NOEXCEPT { return pn < rhs.pn; } @@ -222,17 +233,17 @@ private: #endif - T * px; // contained pointer + element_type * px; // contained pointer boost::detail::weak_count pn; // reference counter }; // weak_ptr -template<class T, class U> inline bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b) +template<class T, class U> inline bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b) BOOST_NOEXCEPT { return a.owner_before( b ); } -template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b) +template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b) BOOST_NOEXCEPT { a.swap(b); } |