Move away from boost

release/4.3a0
Fan Jiang 2020-06-22 15:18:31 -04:00
parent eab53f69de
commit 8f923fa081
1 changed files with 10 additions and 3 deletions

View File

@ -22,21 +22,28 @@
#include <Eigen/Core>
#include <boost/make_shared.hpp>
#include <boost/utility/enable_if.hpp>
#include <type_traits>
#if __cplusplus <= 201103L
namespace gtsam {
template<bool B, class T = void>
using enable_if_t = typename std::enable_if<B, T>::type;
}
#endif
namespace gtsam {
/// Add our own `make_shared` as a layer of wrapping on `boost::make_shared`
template<typename T, typename ... Args>
boost::enable_if_t<has_custom_allocator<T>::value, boost::shared_ptr<T>> make_shared(Args&&... args)
gtsam::enable_if_t<has_custom_allocator<T>::value, boost::shared_ptr<T>> make_shared(Args&&... args)
{
return boost::allocate_shared<T>(Eigen::aligned_allocator<T>(), std::forward<Args> (args)...);
}
/// Fall back to the boost version if no need for alignment
template<typename T, typename ... Args>
boost::enable_if_t<!has_custom_allocator<T>::value, boost::shared_ptr<T>> make_shared(Args&&... args)
gtsam::enable_if_t<!has_custom_allocator<T>::value, boost::shared_ptr<T>> make_shared(Args&&... args)
{
return boost::make_shared<T>(std::forward<Args> (args)...);
}