Minor cosmetic change in detail array_deleter

[SVN r81685]
This commit is contained in:
Glen Fernandes
2012-12-03 05:56:17 +00:00
parent 5e5ff387fa
commit 1adf546ddb

View File

@@ -1,9 +1,9 @@
/* /*
* Copyright (c) 2012 Glen Joseph Fernandes * Copyright (c) 2012 Glen Joseph Fernandes
* glenfe at live dot com * glenfe at live dot com
* *
* Distributed under the Boost Software License, * Distributed under the Boost Software License,
* Version 1.0. (See accompanying file LICENSE_1_0.txt * Version 1.0. (See accompanying file LICENSE_1_0.txt
* or copy at http://boost.org/LICENSE_1_0.txt) * or copy at http://boost.org/LICENSE_1_0.txt)
*/ */
#ifndef BOOST_SMART_PTR_DETAIL_ARRAY_DELETER_HPP #ifndef BOOST_SMART_PTR_DETAIL_ARRAY_DELETER_HPP
@@ -19,7 +19,7 @@ namespace boost {
template<typename T> template<typename T>
class array_deleter<T[]> { class array_deleter<T[]> {
public: public:
array_deleter(std::size_t size) array_deleter(std::size_t size)
: size(size), : size(size),
object(0) { object(0) {
} }
@@ -27,66 +27,66 @@ namespace boost {
destroy(size); destroy(size);
} }
void construct(T* memory) { void construct(T* memory) {
object = memory; std::size_t i = 0;
for (std::size_t i = 0; i < size; i++) { try {
try { for (object = memory; i < size; i++) {
void* p1 = memory + i; void* p1 = memory + i;
::new(p1) T(); ::new(p1) T();
} catch (...) {
destroy(i);
throw;
} }
} catch (...) {
destroy(i);
throw;
} }
} }
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS) #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
template<typename... Args> template<typename... Args>
void construct(T* memory, Args&&... args) { void construct(T* memory, Args&&... args) {
object = memory; std::size_t i = 0;
for (std::size_t i = 0; i < size; i++) { try {
try { for (object = memory; i < size; i++) {
void* p1 = memory + i; void* p1 = memory + i;
::new(p1) T(args...); ::new(p1) T(args...);
} catch (...) {
destroy(i);
throw;
} }
} catch (...) {
destroy(i);
throw;
} }
} }
#endif #endif
void construct_list(T* memory, const T* list) { void construct_list(T* memory, const T* list) {
object = memory; std::size_t i = 0;
for (std::size_t i = 0; i < size; i++) { try {
try { for (object = memory; i < size; i++) {
void* p1 = memory + i; void* p1 = memory + i;
::new(p1) T(list[i]); ::new(p1) T(list[i]);
} catch (...) {
destroy(i);
throw;
} }
} catch (...) {
destroy(i);
throw;
} }
} }
void construct_list(T* memory, const T* list, std::size_t n) { void construct_list(T* memory, const T* list, std::size_t n) {
object = memory; std::size_t i = 0;
for (std::size_t i = 0; i < size; i++) { try {
try { for (object = memory; i < size; i++) {
void* p1 = memory + i; void* p1 = memory + i;
::new(p1) T(list[i % n]); ::new(p1) T(list[i % n]);
} catch (...) {
destroy(i);
throw;
} }
} catch (...) {
destroy(i);
throw;
} }
} }
void construct_noinit(T* memory) { void construct_noinit(T* memory) {
object = memory; std::size_t i = 0;
for (std::size_t i = 0; i < size; i++) { try {
try { for (object = memory; i < size; i++) {
void* p1 = memory + i; void* p1 = memory + i;
::new(p1) T; ::new(p1) T;
} catch (...) {
destroy(i);
throw;
} }
} catch (...) {
destroy(i);
throw;
} }
} }
void operator()(const void*) { void operator()(const void*) {
@@ -107,73 +107,73 @@ namespace boost {
template<typename T, std::size_t N> template<typename T, std::size_t N>
class array_deleter<T[N]> { class array_deleter<T[N]> {
public: public:
array_deleter() array_deleter()
: object(0) { : object(0) {
} }
~array_deleter() { ~array_deleter() {
destroy(N); destroy(N);
} }
void construct(T* memory) { void construct(T* memory) {
object = memory; std::size_t i = 0;
for (std::size_t i = 0; i < N; i++) { try {
try { for (object = memory; i < N; i++) {
void* p1 = memory + i; void* p1 = memory + i;
::new(p1) T(); ::new(p1) T();
} catch (...) {
destroy(i);
throw;
} }
} catch (...) {
destroy(i);
throw;
} }
} }
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS) #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
template<typename... Args> template<typename... Args>
void construct(T* memory, Args&&... args) { void construct(T* memory, Args&&... args) {
object = memory; std::size_t i = 0;
for (std::size_t i = 0; i < N; i++) { try {
try { for (object = memory; i < N; i++) {
void* p1 = memory + i; void* p1 = memory + i;
::new(p1) T(args...); ::new(p1) T(args...);
} catch (...) {
destroy(i);
throw;
} }
} catch (...) {
destroy(i);
throw;
} }
} }
#endif #endif
void construct_list(T* memory, const T* list) { void construct_list(T* memory, const T* list) {
object = memory; std::size_t i = 0;
for (std::size_t i = 0; i < N; i++) { try {
try { for (object = memory; i < N; i++) {
void* p1 = memory + i; void* p1 = memory + i;
::new(p1) T(list[i]); ::new(p1) T(list[i]);
} catch (...) {
destroy(i);
throw;
} }
} catch (...) {
destroy(i);
throw;
} }
} }
void construct_list(T* memory, const T* list, std::size_t n) { void construct_list(T* memory, const T* list, std::size_t n) {
object = memory; std::size_t i = 0;
for (std::size_t i = 0; i < N; i++) { try {
try { for (object = memory; i < N; i++) {
void* p1 = memory + i; void* p1 = memory + i;
::new(p1) T(list[i % n]); ::new(p1) T(list[i % n]);
} catch (...) {
destroy(i);
throw;
} }
} catch (...) {
destroy(i);
throw;
} }
} }
void construct_noinit(T* memory) { void construct_noinit(T* memory) {
object = memory; std::size_t i = 0;
for (std::size_t i = 0; i < N; i++) { try {
try { for (object = memory; i < N; i++) {
void* p1 = memory + i; void* p1 = memory + i;
::new(p1) T; ::new(p1) T;
} catch (...) {
destroy(i);
throw;
} }
} catch (...) {
destroy(i);
throw;
} }
} }
void operator()(const void*) { void operator()(const void*) {