Address Frank's comments

release/4.3a0
Fan Jiang 2020-06-22 13:37:50 -04:00
parent 693253f376
commit eab53f69de
1 changed files with 7 additions and 7 deletions

View File

@ -17,28 +17,28 @@
#pragma once
#include <boost/make_shared.hpp>
#include <gtsam/base/types.h>
#include <boost/type_traits.hpp>
#include <Eigen/Core>
#include <boost/make_shared.hpp>
#include <boost/utility/enable_if.hpp>
namespace gtsam {
/**
* And our own `make_shared` as a layer of wrapping on `boost::make_shared`
*/
/// 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)
{
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)
{
return boost::make_shared<T>(std::forward<Args> (args)...);
}
}
}