summaryrefslogtreecommitdiff
path: root/src/common/include/gudhi/Simple_object_pool.h
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-10-05 09:04:17 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-10-05 09:04:17 +0000
commite6962acc2045831e8b2f1b0b4f10717b4c89971c (patch)
tree913a17ce0455b23f44d393ca0c046511a6c4c01d /src/common/include/gudhi/Simple_object_pool.h
parenta19368075090f5409dc12081df944f90353eb5df (diff)
cpplint fixes
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@822 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 1cab7ed83b02fd90ab57550ad5363dc36f8b8d05
Diffstat (limited to 'src/common/include/gudhi/Simple_object_pool.h')
-rw-r--r--src/common/include/gudhi/Simple_object_pool.h57
1 files changed, 37 insertions, 20 deletions
diff --git a/src/common/include/gudhi/Simple_object_pool.h b/src/common/include/gudhi/Simple_object_pool.h
index fffcb2ef..fb9c8e23 100644
--- a/src/common/include/gudhi/Simple_object_pool.h
+++ b/src/common/include/gudhi/Simple_object_pool.h
@@ -20,45 +20,62 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifndef SIMPLE_OBJECT_POOL_H_
+#define SIMPLE_OBJECT_POOL_H_
+
#include <boost/pool/pool.hpp>
#include <utility>
namespace Gudhi {
- /** \private
- * This is a simpler version of boost::object_pool, that requires
- * that users explicitly destroy all objects. This lets the
- * performance scale much better, see
- * https://svn.boost.org/trac/boost/ticket/3789 .
- */
+
+/** \private
+ * This is a simpler version of boost::object_pool, that requires
+ * that users explicitly destroy all objects. This lets the
+ * performance scale much better, see
+ * https://svn.boost.org/trac/boost/ticket/3789 .
+ */
template <class T>
-class Simple_object_pool : protected boost::pool<boost::default_user_allocator_malloc_free>
-{
- protected:
+class Simple_object_pool : protected boost::pool<boost::default_user_allocator_malloc_free> {
+ protected:
typedef boost::pool<boost::default_user_allocator_malloc_free> Base;
typedef T* pointer;
- Base& base(){return *this;}
- Base const& base()const{return *this;}
- public:
+
+ Base& base() {
+ return *this;
+ }
+
+ Base const& base()const {
+ return *this;
+ }
+
+ public:
typedef T element_type;
typedef boost::default_user_allocator_malloc_free user_allocator;
typedef typename Base::size_type size_type;
typedef typename Base::difference_type difference_type;
+
template<class...U>
- Simple_object_pool(U&&...u) : Base(sizeof(T), std::forward<U>(u)...) {}
+ Simple_object_pool(U&&...u) : Base(sizeof (T), std::forward<U>(u)...) { }
+
template<class...U>
- pointer construct(U&&...u){
- void* p=base().malloc BOOST_PREVENT_MACRO_SUBSTITUTION();
+ pointer construct(U&&...u) {
+ void* p = base().malloc BOOST_PREVENT_MACRO_SUBSTITUTION();
assert(p);
- try { new(p) T(std::forward<U>(u)...); }
- catch(...) {
+ try {
+ new(p) T(std::forward<U>(u)...);
+ } catch (...) {
base().free BOOST_PREVENT_MACRO_SUBSTITUTION(p);
throw;
}
- return static_cast<pointer>(p);
+ return static_cast<pointer> (p);
}
- void destroy(pointer p){
+
+ void destroy(pointer p) {
p->~T();
base().free BOOST_PREVENT_MACRO_SUBSTITUTION(p);
}
};
-}
+
+} // namespace Gudhi
+
+#endif // SIMPLE_OBJECT_POOL_H_