Update to C++17.

This can be reverted easily, but let’s see if it goes.
This commit is contained in:
James Turner 2020-06-22 20:39:45 +01:00
parent 346344ee09
commit abb73c566e
6 changed files with 19 additions and 107 deletions

View File

@ -35,7 +35,7 @@ include (GenerateExportHeader)
set(CMAKE_OSX_RPATH 1)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
# read 'version' file into a variable (stripping any newlines or spaces)
@ -444,7 +444,7 @@ if(WIN32)
endif()
if(MSVC)
set(MSVC_FLAGS "-DWIN32 -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS /MP")
set(MSVC_FLAGS "-D_HAS_STD_BYTE=0 -DWIN32 -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS /MP /bigobj")
if (X86)
set(SIMD_COMPILER_FLAGS "/arch:SSE /arch:SSE2")
endif()
@ -455,11 +455,6 @@ if(WIN32)
# symbols. Suspect this may be an OSG-DB export bug
set( MSVC_LD_FLAGS "/FORCE:MULTIPLE" )
endif ()
if (${MSVC_VERSION} GREATER 1899)
# needed for debug builds with VS2015
set( MSVC_FLAGS "${MSVC_FLAGS} /bigobj" )
endif()
endif(MSVC)
# assumed on Windows

View File

@ -62,7 +62,7 @@ public:
};
typedef std::list<LeafRef> LeafRefList;
struct LeafRefLess : public std::binary_function<LeafRef, LeafRef, bool> {
struct LeafRefLess {
LeafRefLess(unsigned sortAxis) : _sortAxis(sortAxis) {}
bool operator()(const LeafRef& x, const LeafRef& y)
{ return x._center[_sortAxis] < y._center[_sortAxis]; }

27
simgear/nasal/cppbind/NasalString.cxx Normal file → Executable file
View File

@ -28,28 +28,6 @@
namespace nasal
{
/**
* Predicate (eg. for std::find_if) returning true if no character of the
* stored string given by the range [begin, end) matches.
*/
struct no_match:
public std::unary_function<const char, bool>
{
no_match(const char* begin, const char* end):
_begin(begin),
_end(end)
{}
bool operator()(const char c) const
{
return std::find(_begin, _end, c) == _end;
}
private:
const char* _begin;
const char* _end;
};
//template<typename Iterator>
//Iterator
//rfind_first_of( Iterator rbegin_src, Iterator rend_src,
@ -171,8 +149,9 @@ namespace nasal
if( pos >= size() )
return npos;
const char* result = std::find_if( begin() + pos, end(),
no_match(chr.begin(), chr.end()) );
const char* result = std::find_if(begin() + pos, end(), [&chr](const char c) {
return std::find(chr.begin(), chr.end(), c) == chr.end();
});
return result != end() ? result - begin() : npos;
}

14
simgear/props/props.cxx Normal file → Executable file
View File

@ -2829,25 +2829,25 @@ size_t hash_value(const SGPropertyNode& node)
return 0;
case props::BOOL:
return hash_value(node.getValue<bool>());
return boost::hash_value(node.getValue<bool>());
case props::INT:
return hash_value(node.getValue<int>());
return boost::hash_value(node.getValue<int>());
case props::LONG:
return hash_value(node.getValue<long>());
return boost::hash_value(node.getValue<long>());
case props::FLOAT:
return hash_value(node.getValue<float>());
return boost::hash_value(node.getValue<float>());
case props::DOUBLE:
return hash_value(node.getValue<double>());
return boost::hash_value(node.getValue<double>());
case props::STRING:
case props::UNSPECIFIED:
{
const char *val = node.getStringValue();
return hash_range(val, val + strlen(val));
return boost::hash_range(val, val + strlen(val));
}
case props::VEC3D:
{
const SGVec3d val = node.getValue<SGVec3d>();
return hash_range(&val[0], &val[3]);
return boost::hash_range(&val[0], &val[3]);
}
case props::VEC4D:
{

View File

@ -57,19 +57,6 @@ OpenThreads::ReentrantMutex effectMutex;
* Nodes are considered equal if their names and indexes are equal.
*/
struct PropPredicate
: public unary_function<const SGPropertyNode*, bool>
{
PropPredicate(const SGPropertyNode* node_) : node(node_) {}
bool operator()(const SGPropertyNode* arg) const
{
if (strcmp(node->getName(), arg->getName()))
return false;
return node->getIndex() == arg->getIndex();
}
const SGPropertyNode* node;
};
namespace effect
{
void mergePropertyTrees(SGPropertyNode* resultNode,
@ -86,9 +73,12 @@ void mergePropertyTrees(SGPropertyNode* resultNode,
// Merge identical nodes
for (int i = 0; i < right->nChildren(); ++i) {
const SGPropertyNode* node = right->getChild(i);
RawPropVector::iterator litr
= find_if(leftChildren.begin(), leftChildren.end(),
PropPredicate(node));
auto litr = find_if(leftChildren.begin(), leftChildren.end(),
[node](const SGPropertyNode* arg) {
if (strcmp(node->getName(), arg->getName()))
return false;
return node->getIndex() == arg->getIndex();
});
SGPropertyNode* newChild
= resultNode->getChild(node->getName(), node->getIndex(), true);
if (litr != leftChildren.end()) {

View File

@ -24,58 +24,6 @@
#include <osg/StateAttribute>
#include <osg/StateSet>
namespace simgear
{
// RefPtrAdapter also appears in OpenSceneGraph's
// osgDB/DatabasePager.cpp. I wrote that code too. -- Tim Moore
// Convert function objects that take pointer args into functions that a
// reference to an osg::ref_ptr. This is quite useful for doing STL
// operations on lists of ref_ptr. This code assumes that a function
// with an argument const Foo* should be composed into a function of
// argument type ref_ptr<Foo>&, not ref_ptr<const Foo>&. Some support
// for that should be added to make this more general.
template <typename U>
struct PointerTraits
{
typedef class NullType {} PointeeType;
};
template <typename U>
struct PointerTraits<U*>
{
typedef U PointeeType;
};
template <typename U>
struct PointerTraits<const U*>
{
typedef U PointeeType;
};
template <typename FuncObj>
class RefPtrAdapter
: public std::unary_function<const osg::ref_ptr<typename PointerTraits<typename FuncObj::argument_type>::PointeeType>,
typename FuncObj::result_type>
{
public:
typedef typename PointerTraits<typename FuncObj::argument_type>::PointeeType PointeeType;
typedef osg::ref_ptr<PointeeType> RefPtrType;
explicit RefPtrAdapter(const FuncObj& funcObj) : _func(funcObj) {}
typename FuncObj::result_type operator()(const RefPtrType& refPtr) const
{
return _func(refPtr.get());
}
protected:
FuncObj _func;
};
template <typename FuncObj>
RefPtrAdapter<FuncObj> refPtrAdapt(const FuncObj& func)
{
return RefPtrAdapter<FuncObj>(func);
}
}
/** Typesafe wrapper around OSG's object clone function. Something
* very similar is in current OSG sources.
*/