Make common interface to shared_ptr available
Use configure-time checks to find an available implementation of shared_ptr from the standard library (C++11), TR1 (C++03), or Boost.
This commit is contained in:
parent
06732a6581
commit
fbe8a7cd3f
3 changed files with 58 additions and 1 deletions
20
SConstruct
20
SConstruct
|
|
@ -794,6 +794,8 @@ def get_expression_value(includes, expression):
|
|||
'}\n'))
|
||||
return '\n'.join(s)
|
||||
|
||||
configh = {}
|
||||
|
||||
env['HAS_TIMES_H'] = conf.CheckCHeader('sys/times.h', '""')
|
||||
env['HAS_UNISTD_H'] = conf.CheckCHeader('unistd.h', '""')
|
||||
#
|
||||
|
|
@ -814,6 +816,22 @@ boost_version_source = get_expression_value(['<boost/version.hpp>'], 'BOOST_LIB_
|
|||
retcode, boost_lib_version = conf.TryRun(boost_version_source, '.cpp')
|
||||
env['BOOST_LIB_VERSION'] = boost_lib_version.strip()
|
||||
|
||||
# Find shared pointer implementation
|
||||
configh['CT_USE_STD_SHARED_PTR'] = None
|
||||
configh['CT_USE_TR1_SHARED_PTR'] = None
|
||||
configh['CT_USE_MSFT_SHARED_PTR'] = None
|
||||
configh['CT_USE_BOOST_SHARED_PTR'] = None
|
||||
if conf.CheckStatement('std::shared_ptr<int> x', '#include <memory>'):
|
||||
configh['CT_USE_STD_SHARED_PTR'] = 1
|
||||
elif conf.CheckStatement('std::tr1::shared_ptr<int> x', '#include <tr1/memory>'):
|
||||
configh['CT_USE_TR1_SHARED_PTR'] = 1
|
||||
elif conf.CheckStatement('std::tr1::shared_ptr<int> x', '#include <memory>'):
|
||||
configh['CT_USE_MSFT_SHARED_PTR'] = 1
|
||||
elif conf.CheckStatement('boost::shared_ptr<int> x', '#include <boost/shared_ptr.hpp>'):
|
||||
configh['CT_USE_BOOST_SHARED_PTR'] = 1
|
||||
else:
|
||||
config_error("Couldn't find a working shared_ptr implementation.")
|
||||
|
||||
import SCons.Conftest, SCons.SConf
|
||||
ret = SCons.Conftest.CheckLib(SCons.SConf.CheckContext(conf),
|
||||
['sundials_cvodes'],
|
||||
|
|
@ -1192,7 +1210,7 @@ else:
|
|||
# *** Set options needed in config.h ***
|
||||
# **************************************
|
||||
|
||||
configh = {'CANTERA_VERSION': quoted(env['cantera_version'])}
|
||||
configh['CANTERA_VERSION'] = quoted(env['cantera_version'])
|
||||
|
||||
# Conditional defines
|
||||
def cdefine(definevar, configvar, comp=True, value=1):
|
||||
|
|
|
|||
|
|
@ -55,6 +55,12 @@ typedef int ftnlen; // Fortran hidden string length type
|
|||
%(LAPACK_NAMES_LOWERCASE)s
|
||||
%(LAPACK_FTN_TRAILING_UNDERSCORE)s
|
||||
|
||||
//--------- shared_ptr implementation ---------
|
||||
%(CT_USE_STD_SHARED_PTR)s
|
||||
%(CT_USE_TR1_SHARED_PTR)s
|
||||
%(CT_USE_MSFT_SHARED_PTR)s
|
||||
%(CT_USE_BOOST_SHARED_PTR)s
|
||||
|
||||
//-------- BOOST --------
|
||||
%(USE_BOOST_MATH)s
|
||||
|
||||
|
|
|
|||
33
include/cantera/base/smart_ptr.h
Normal file
33
include/cantera/base/smart_ptr.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "config.h"
|
||||
|
||||
#if defined CT_USE_STD_SHARED_PTR
|
||||
#include <memory>
|
||||
namespace Cantera
|
||||
{
|
||||
using std::shared_ptr;
|
||||
}
|
||||
|
||||
#elif defined CT_USE_TR1_SHARED_PTR
|
||||
#include <tr1/memory>
|
||||
namespace Cantera
|
||||
{
|
||||
using std::tr1::shared_ptr;
|
||||
}
|
||||
|
||||
#elif defined CT_USE_MSFT_SHARED_PTR
|
||||
#include <memory>
|
||||
namespace Cantera
|
||||
{
|
||||
using std::tr1::shared_ptr;
|
||||
}
|
||||
|
||||
#elif defined CT_USE_BOOST_SHARED_PTR
|
||||
#include <boost/shared_ptr.hpp>
|
||||
namespace Cantera
|
||||
{
|
||||
using boost::shared_ptr;
|
||||
}
|
||||
|
||||
#else
|
||||
#error "No shared_ptr implementation available"
|
||||
#endif
|
||||
Loading…
Add table
Reference in a new issue