2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
20 * @brief This file is the implementation file of scoped array RAII
22 * This module is deprecated, please use standard C++11 feature: std::unique_ptr<Type[]>
24 #ifndef DPL_SCOPED_ARRAY_H
25 #define DPL_SCOPED_ARRAY_H
29 #include <dpl/assert.h>
30 #include <dpl/scoped_resource.h>
31 #include <dpl/availability.h>
34 template<typename Class>
35 struct ScopedArrayPolicy
38 static Type NullValue()
42 static void Destroy(Type ptr)
48 template<typename Class>
49 class ScopedArray : public ScopedResource<ScopedArrayPolicy<Class> >
51 typedef ScopedArrayPolicy<Class> Policy;
52 typedef ScopedResource<Policy> BaseType;
55 explicit ScopedArray(Class *ptr = Policy::NullValue()) : BaseType(ptr) { }
57 Class &operator [](std::ptrdiff_t k) const
59 Assert(this->m_value != Policy::NullValue() &&
60 "Dereference of scoped NULL array!");
61 Assert(k >= 0 && "Negative array index");
63 return this->m_value[k];
65 } DPL_DEPRECATED_WITH_MESSAGE("use standard C++11 feature: std::unique_ptr<Type[]>");
68 #endif // DPL_SCOPED_PTR_H