Replace boost::enable_if/disable_if/enable_if_c/disable_if_c by std::enable_if

This commit is contained in:
gallaert 2020-04-19 12:18:24 +01:00 committed by James Turner
parent 1e13cf6fec
commit d21137739d
4 changed files with 29 additions and 72 deletions

View File

@ -1230,7 +1230,7 @@ namespace nasal
// Either const CallContext& or CallContext, non-const reference
// does not make sense.
static_assert(
!boost::is_same<Arg, CallContext&>::value,
!std::is_same<Arg, CallContext&>::value,
"Only const reference and value make sense!");
return ctx;
};

View File

@ -24,11 +24,6 @@
#include <simgear/structure/map.hxx>
#include <boost/iterator/iterator_facade.hpp>
#if BOOST_VERSION >= 105600
#include <boost/core/enable_if.hpp>
#else
#include <boost/utility/enable_if.hpp>
#endif
namespace nasal
{
@ -125,8 +120,8 @@ namespace nasal
* @param name Member name
*/
template<class Sig, class Key>
typename boost::enable_if< boost::is_function<Sig>,
boost::function<Sig>
typename std::enable_if< std::is_function<Sig>::value,
std::function<Sig>
>::type
get(const Key& name) const
{
@ -242,7 +237,7 @@ namespace nasal
*/
template<bool is_other_const>
Iterator( Iterator<is_other_const> const& other,
typename boost::enable_if_c< is_const || !is_other_const,
typename std::enable_if< is_const || !is_other_const,
void*
>::type = NULL ):
_hash(other._hash),

View File

@ -24,44 +24,13 @@
#include <simgear/compiler.h>
#if PROPS_STANDALONE
// taken from: boost/utility/enable_if.hpp
# ifndef SG_LOG
# define SG_GENERAL 0
# define SG_ALERT 0
# define SG_WARN 1
# define SG_LOG(type, level, message) (type) ? (std::cerr <<message << endl) : (std::cout <<message << endl)
# endif
namespace boost {
template <bool B, class T = void>
struct enable_if_c {
typedef T type;
};
template <class T>
struct enable_if_c<false, T> {};
template <class Cond, class T = void>
struct enable_if : public enable_if_c<Cond::value, T> {};
template <bool B, class T = void>
struct disable_if_c {
typedef T type;
};
template <class T>
struct disable_if_c<true, T> {};
template <class Cond, class T = void>
struct disable_if : public disable_if_c<Cond::value, T> {};
}
#else
# include <boost/type_traits/is_enum.hpp>
#if BOOST_VERSION >= 105600
#include <boost/core/enable_if.hpp>
#else
#include <boost/utility/enable_if.hpp>
#endif
# include <simgear/debug/logstream.hxx>
# include <simgear/math/SGMathFwd.hxx>
# include <simgear/math/sg_types.hxx>
@ -1263,11 +1232,11 @@ public:
* match the desired type, a conversion isn't guaranteed.
*/
template<typename T>
T getValue(typename boost::enable_if_c<simgear::props::PropertyTraits<T>::Internal>
T getValue(typename std::enable_if<simgear::props::PropertyTraits<T>::Internal>
::type* dummy = 0) const;
// Getter for extended property
template<typename T>
T getValue(typename boost::disable_if_c<simgear::props::PropertyTraits<T>::Internal>
T getValue(typename std::enable_if<!simgear::props::PropertyTraits<T>::Internal>
::type* dummy = 0) const;
/**
@ -1331,12 +1300,12 @@ public:
template<typename T>
bool setValue(const T& val,
typename boost::enable_if_c<simgear::props::PropertyTraits<T>::Internal>
typename std::enable_if<simgear::props::PropertyTraits<T>::Internal>
::type* dummy = 0);
template<typename T>
bool setValue(const T& val,
typename boost::disable_if_c<simgear::props::PropertyTraits<T>::Internal>
typename std::enable_if<!simgear::props::PropertyTraits<T>::Internal>
::type* dummy = 0);
template<int N>
@ -1899,7 +1868,7 @@ template<typename T>
#if PROPS_STANDALONE
T
#else
typename boost::disable_if<boost::is_enum<T>, T>::type
typename std::enable_if<!std::is_enum<T>::value, T>::type
#endif
getValue(const SGPropertyNode*);
@ -1967,7 +1936,7 @@ template<typename T>
#if PROPS_STANDALONE
inline T
#else
inline typename boost::enable_if<boost::is_enum<T>, T>::type
inline typename std::enable_if<std::is_enum<T>::value, T>::type
#endif
getValue(const SGPropertyNode* node)
{
@ -2053,7 +2022,7 @@ bool SGPropertyNode::tie (const SGRawValue<const char *> &rawValue,
bool useDefault);
template<typename T>
T SGPropertyNode::getValue(typename boost::disable_if_c<simgear::props
T SGPropertyNode::getValue(typename std::enable_if<!simgear::props
::PropertyTraits<T>::Internal>::type* dummy) const
{
using namespace simgear::props;
@ -2081,7 +2050,7 @@ T SGPropertyNode::getValue(typename boost::disable_if_c<simgear::props
}
template<typename T>
inline T SGPropertyNode::getValue(typename boost::enable_if_c<simgear::props
inline T SGPropertyNode::getValue(typename std::enable_if<simgear::props
::PropertyTraits<T>::Internal>::type* dummy) const
{
return ::getValue<T>(this);
@ -2108,7 +2077,7 @@ std::vector<T> SGPropertyNode::getChildValues(const std::string& name) const
template<typename T>
bool SGPropertyNode::setValue(const T& val,
typename boost::disable_if_c<simgear::props
typename std::enable_if<!simgear::props
::PropertyTraits<T>::Internal>::type* dummy)
{
using namespace simgear::props;
@ -2137,7 +2106,7 @@ bool SGPropertyNode::setValue(const T& val,
template<typename T>
inline bool SGPropertyNode::setValue(const T& val,
typename boost::enable_if_c<simgear::props
typename std::enable_if<simgear::props
::PropertyTraits<T>::Internal>::type* dummy)
{
return ::setValue(this, val);

View File

@ -21,13 +21,6 @@
#include "SGReferenced.hxx"
#include "SGSharedPtr.hxx"
#include <boost/type_traits/is_base_of.hpp>
#if BOOST_VERSION >= 105600
#include <boost/core/enable_if.hpp>
#else
#include <boost/utility/enable_if.hpp>
#endif
#ifdef _MSC_VER
# pragma warning(push)
// C4355: 'this' : used in base member initializer list
@ -121,8 +114,8 @@ private:
/// Upcast in a class hierarchy with a virtual base class
template<class T>
static
typename boost::enable_if<
boost::is_base_of<SGVirtualWeakReferenced, T>,
typename std::enable_if<
std::is_base_of<SGVirtualWeakReferenced, T>::value,
T*
>::type
up_cast(SGWeakReferenced* ptr);
@ -130,8 +123,8 @@ private:
/// Upcast in a non-virtual class hierarchy
template<class T>
static
typename boost::disable_if<
boost::is_base_of<SGVirtualWeakReferenced, T>,
typename std::enable_if<
!std::is_base_of<SGVirtualWeakReferenced, T>::value,
T*
>::type
up_cast(SGWeakReferenced* ptr)
@ -185,8 +178,8 @@ class SGVirtualWeakReferenced:
/// Upcast in a class hierarchy with a virtual base class
// We (clang) need the definition of SGVirtualWeakReferenced for the static_cast
template<class T>
typename boost::enable_if<
boost::is_base_of<SGVirtualWeakReferenced, T>,
typename std::enable_if<
std::is_base_of<SGVirtualWeakReferenced, T>::value,
T*
>::type
SGWeakReferenced::WeakData::up_cast(SGWeakReferenced* ptr)