Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82432 - in branches/release: . boost boost/smart_ptr boost/smart_ptr/detail
From: glenfe_at_[hidden]
Date: 2013-01-10 11:50:34


Author: glenfe
Date: 2013-01-10 11:50:34 EST (Thu, 10 Jan 2013)
New Revision: 82432
URL: http://svn.boost.org/trac/boost/changeset/82432

Log:
Merge revision 82408 from trunk:
Support BOOST_NO_EXCEPTIONS in detail/array_utility.hpp to allow use when exceptions are disabled
........

Properties modified:
   branches/release/ (props changed)
   branches/release/boost/ (props changed)
   branches/release/boost/smart_ptr/ (props changed)
Text files modified:
   branches/release/boost/smart_ptr/detail/array_utility.hpp | 42 ++++++++++++++++++++++++++++++++++++++++
   1 files changed, 42 insertions(+), 0 deletions(-)

Modified: branches/release/boost/smart_ptr/detail/array_utility.hpp
==============================================================================
--- branches/release/boost/smart_ptr/detail/array_utility.hpp (original)
+++ branches/release/boost/smart_ptr/detail/array_utility.hpp 2013-01-10 11:50:34 EST (Thu, 10 Jan 2013)
@@ -37,6 +37,7 @@
         }
         template<typename T>
         inline void array_init(T* memory, std::size_t size, boost::false_type) {
+#if !defined(BOOST_NO_EXCEPTIONS)
             std::size_t i = 0;
             try {
                 for (; i < size; i++) {
@@ -47,6 +48,12 @@
                 array_destroy(memory, i);
                 throw;
             }
+#else
+ for (std::size_t i = 0; i < size; i++) {
+ void* p1 = memory + i;
+ ::new(p1) T();
+ }
+#endif
         }
         template<typename T>
         inline void array_init(T* memory, std::size_t size) {
@@ -56,6 +63,7 @@
 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
         template<typename T>
         inline void array_init_value(T* memory, std::size_t size, T&& value) {
+#if !defined(BOOST_NO_EXCEPTIONS)
             std::size_t i = 0;
             try {
                 for (; i < size; i++) {
@@ -66,10 +74,17 @@
                 array_destroy(memory, i);
                 throw;
             }
+#else
+ for (std::size_t i = 0; i < size; i++) {
+ void* p1 = memory + i;
+ ::new(p1) T(value);
+ }
+#endif
         }
 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
         template<typename T, typename... Args>
         inline void array_init_args(T* memory, std::size_t size, Args&&... args) {
+#if !defined(BOOST_NO_EXCEPTIONS)
             std::size_t i = 0;
             try {
                 for (; i < size; i++) {
@@ -80,11 +95,18 @@
                 array_destroy(memory, i);
                 throw;
             }
+#else
+ for (std::size_t i = 0; i < size; i++) {
+ void* p1 = memory + i;
+ ::new(p1) T(args...);
+ }
+#endif
         }
 #endif
 #endif
         template<typename T>
         inline void array_init_list(T* memory, std::size_t size, const T* list) {
+#if !defined(BOOST_NO_EXCEPTIONS)
             std::size_t i = 0;
             try {
                 for (; i < size; i++) {
@@ -95,9 +117,16 @@
                 array_destroy(memory, i);
                 throw;
             }
+#else
+ for (std::size_t i = 0; i < size; i++) {
+ void* p1 = memory + i;
+ ::new(p1) T(list[i]);
+ }
+#endif
         }
         template<typename T, std::size_t N>
         inline void array_init_list(T* memory, std::size_t size, const T* list) {
+#if !defined(BOOST_NO_EXCEPTIONS)
             std::size_t i = 0;
             try {
                 for (; i < size; i++) {
@@ -108,12 +137,19 @@
                 array_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
         }
         template<typename T>
         inline void array_noinit(T*, std::size_t, boost::true_type) {
         }
         template<typename T>
         inline void array_noinit(T* memory, std::size_t size, boost::false_type) {
+#if !defined(BOOST_NO_EXCEPTIONS)
             std::size_t i = 0;
             try {
                 for (; i < size; i++) {
@@ -124,6 +160,12 @@
                 array_destroy(memory, i);
                 throw;
             }
+#else
+ for (std::size_t i = 0; i < size; i++) {
+ void* p1 = memory + i;
+ ::new(p1) T;
+ }
+#endif
         }
         template<typename T>
         inline void array_noinit(T* memory, std::size_t size) {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk