Skip to content
Snippets Groups Projects
Commit cc4915bb authored by Enrico Guiraud's avatar Enrico Guiraud Committed by Danilo Piparo
Browse files

[VecOps][NFC] Formatting of RAdoptAllocator

parent 5927f141
No related branches found
No related tags found
No related merge requests found
...@@ -47,7 +47,6 @@ v.emplace_back(0.); ...@@ -47,7 +47,6 @@ v.emplace_back(0.);
now the vector *v* owns its memory as a regular vector. now the vector *v* owns its memory as a regular vector.
**/ **/
template <typename T> template <typename T>
class RAdoptAllocator { class RAdoptAllocator {
public: public:
...@@ -61,8 +60,11 @@ public: ...@@ -61,8 +60,11 @@ public:
using const_reference = typename StdAlloc_t::const_reference; using const_reference = typename StdAlloc_t::const_reference;
using size_type = typename StdAlloc_t::size_type; using size_type = typename StdAlloc_t::size_type;
using difference_type = typename StdAlloc_t::difference_type; using difference_type = typename StdAlloc_t::difference_type;
template<typename U> template <typename U>
struct rebind { using other = RAdoptAllocator<U>; }; struct rebind {
using other = RAdoptAllocator<U>;
};
private: private:
enum class EAllocType : char { kOwning, kAdopting, kAdoptingNoAllocYet }; enum class EAllocType : char { kOwning, kAdopting, kAdoptingNoAllocYet };
using StdAllocTraits_t = std::allocator_traits<StdAlloc_t>; using StdAllocTraits_t = std::allocator_traits<StdAlloc_t>;
...@@ -72,8 +74,7 @@ private: ...@@ -72,8 +74,7 @@ private:
public: public:
/// This is the constructor which allows the allocator to adopt a certain memory region. /// This is the constructor which allows the allocator to adopt a certain memory region.
RAdoptAllocator(pointer p) RAdoptAllocator(pointer p) : fInitialAddress(p), fAllocType(EAllocType::kAdoptingNoAllocYet){};
: fInitialAddress(p), fAllocType(EAllocType::kAdoptingNoAllocYet){};
RAdoptAllocator() = default; RAdoptAllocator() = default;
RAdoptAllocator(const RAdoptAllocator &) = default; RAdoptAllocator(const RAdoptAllocator &) = default;
RAdoptAllocator(RAdoptAllocator &&) = default; RAdoptAllocator(RAdoptAllocator &&) = default;
...@@ -129,27 +130,22 @@ public: ...@@ -129,27 +130,22 @@ public:
bool operator==(const RAdoptAllocator<T> &other) bool operator==(const RAdoptAllocator<T> &other)
{ {
return fInitialAddress == other.fInitialAddress && return fInitialAddress == other.fInitialAddress && fAllocType == other.fAllocType &&
fAllocType == other.fAllocType &&
fStdAllocator == other.fStdAllocator; fStdAllocator == other.fStdAllocator;
} }
bool operator!=(const RAdoptAllocator<T> &other) bool operator!=(const RAdoptAllocator<T> &other) { return !(*this == other); }
{
return !(*this == other);
}
template<class U> template <class U>
void destroy(U* p) void destroy(U *p)
{ {
if (EAllocType::kAdopting != fAllocType) { if (EAllocType::kAdopting != fAllocType) {
fStdAllocator.destroy(p); fStdAllocator.destroy(p);
} }
} }
}; };
} // End NS VecOps } // End NS VecOps
} // End NS Internal } // End NS Detail
} // End NS ROOT } // End NS ROOT
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment