Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/libmv/libmv/base/scoped_ptr.h')
-rw-r--r--intern/libmv/libmv/base/scoped_ptr.h38
1 files changed, 20 insertions, 18 deletions
diff --git a/intern/libmv/libmv/base/scoped_ptr.h b/intern/libmv/libmv/base/scoped_ptr.h
index b9cd4854213..9bfcfe1d615 100644
--- a/intern/libmv/libmv/base/scoped_ptr.h
+++ b/intern/libmv/libmv/base/scoped_ptr.h
@@ -30,44 +30,44 @@ namespace libmv {
* A handle for a heap-allocated resource that should be freed when it goes out
* of scope. This looks similar to the one found in TR1.
*/
-template<typename T>
+template <typename T>
class scoped_ptr {
public:
- scoped_ptr(T *resource) : resource_(resource) {}
+ scoped_ptr(T* resource) : resource_(resource) {}
~scoped_ptr() { reset(0); }
- T *get() const { return resource_; }
- T *operator->() const { return resource_; }
- T &operator*() const { return *resource_; }
+ T* get() const { return resource_; }
+ T* operator->() const { return resource_; }
+ T& operator*() const { return *resource_; }
- void reset(T *new_resource) {
+ void reset(T* new_resource) {
if (sizeof(T)) {
delete resource_;
}
resource_ = new_resource;
}
- T *release() {
- T *released_resource = resource_;
+ T* release() {
+ T* released_resource = resource_;
resource_ = 0;
return released_resource;
}
private:
// No copying allowed.
- T *resource_;
+ T* resource_;
};
// Same as scoped_ptr but caller must allocate the data
// with new[] and the destructor will free the memory
// using delete[].
-template<typename T>
+template <typename T>
class scoped_array {
public:
- scoped_array(T *array) : array_(array) {}
+ scoped_array(T* array) : array_(array) {}
~scoped_array() { reset(NULL); }
- T *get() const { return array_; }
+ T* get() const { return array_; }
T& operator[](std::ptrdiff_t i) const {
assert(i >= 0);
@@ -75,25 +75,27 @@ class scoped_array {
return array_[i];
}
- void reset(T *new_array) {
+ void reset(T* new_array) {
if (sizeof(T)) {
delete array_;
}
array_ = new_array;
}
- T *release() {
- T *released_array = array_;
+ T* release() {
+ T* released_array = array_;
array_ = NULL;
return released_array;
}
private:
- T *array_;
+ T* array_;
// Forbid comparison of different scoped_array types.
- template <typename T2> bool operator==(scoped_array<T2> const& p2) const;
- template <typename T2> bool operator!=(scoped_array<T2> const& p2) const;
+ template <typename T2>
+ bool operator==(scoped_array<T2> const& p2) const;
+ template <typename T2>
+ bool operator!=(scoped_array<T2> const& p2) const;
// Disallow evil constructors
scoped_array(const scoped_array&);