Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit 790797f3 authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Improving the ptr class to use C++ 2011 shared_ptr when it is possible instead...

Improving the ptr class to use C++ 2011 shared_ptr when it is possible instead of our poor implementation.
parent b17d8b86
......@@ -24,6 +24,11 @@ class function : public parametrized
{
public: // methods
/* NEEDED FUNCTIONS */
//! \brief Destructor function needed when using shared_ptr
virtual ~function() {}
/* INTERFACE */
// Overload the function operator
......@@ -81,8 +86,6 @@ class function : public parametrized
//! hemisphere.
double Linf_distance(const data* d) const ;
protected: // data
};
/*! \brief Non-linear function interface
......
#pragma once
/*! \class ptr
*
* Define a shared pointer class for automatic memory cleaning
* when dealing with objects created by plugins. All plugins should
* provide a ptr<object> instead of a object* so that the user won't
* have to worry about allocation/deallocation.
*
* ALTA provide a weak implementation of the ptr class. If a C++11
* compatible is used, it will try to use the STL version of shared
* pointer.
*/
/* Checking for the presence of C++11 features like smart pointers. There
* is no clean way to do it for all compilers. This method is supposed to
* work with CLANG and GCC > 4.3.
*
* See htpp://stackoverflow.com/questions/11886288/
*/
#if __cplusplus >= 201103L
#include <memory>
template<class T> using ptr = std::shared_ptr<T>;
#else
/* Define a counter class. This class should not be used by any other part of
* ALTA code.
*/
......@@ -23,8 +50,6 @@ struct ptr_counter
unsigned int _count;
};
/*! \brief Define a shared pointer class.
*/
template<class T> class ptr
{
public:
......@@ -75,3 +100,4 @@ template<class T> class ptr
T* _ptr;
ptr_counter* _counter;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment