diff --git a/CMakeLists.txt b/CMakeLists.txt index 3db558a870..9fb9304d0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND NOT WIN32 AND CMAKE_COMPILER_IS_ endif() #Activate C++11 -set(CMAKE_CXX_STANDARD 11) # Upgrading to C++17 would need to remove usage of bind2nd (should be easy). +set(CMAKE_CXX_STANDARD 11) # Upgrading to C++17 should be tried. set(CMAKE_CXX_STANDARD_REQUIRED ON) # Mark some warnings as errors diff --git a/Core/GDCore/Project/ExternalLayout.h b/Core/GDCore/Project/ExternalLayout.h index 2a18d5ce15..6c25db8f2d 100644 --- a/Core/GDCore/Project/ExternalLayout.h +++ b/Core/GDCore/Project/ExternalLayout.h @@ -96,19 +96,6 @@ class GD_CORE_API ExternalLayout { gd::String associatedLayout; }; -/** - * \brief Functor testing ExternalLayout' name - */ -struct ExternalLayoutHasName - : public std::binary_function, - gd::String, - bool> { - bool operator()(const std::unique_ptr& externalLayout, - gd::String name) const { - return externalLayout->GetName() == name; - } -}; - } // namespace gd #endif // GDCORE_EXTERNALLAYOUT_H diff --git a/Core/GDCore/Project/Layout.h b/Core/GDCore/Project/Layout.h index ffdfce81dc..f6cbfd4708 100644 --- a/Core/GDCore/Project/Layout.h +++ b/Core/GDCore/Project/Layout.h @@ -405,18 +405,6 @@ class GD_CORE_API Layout { const gd::String& behaviorsType); }; -/** - * \brief Functor testing layout name. - * \see gd::Layout - */ -struct LayoutHasName - : public std::binary_function, gd::String, bool> { - bool operator()(const std::unique_ptr& layout, - gd::String name) const { - return layout->GetName() == name; - } -}; - /** * \brief Get the names of all layers from the given layout * that are invisible. diff --git a/Core/GDCore/Project/Project.cpp b/Core/GDCore/Project/Project.cpp index 4673820d13..77849455ff 100644 --- a/Core/GDCore/Project/Project.cpp +++ b/Core/GDCore/Project/Project.cpp @@ -264,15 +264,21 @@ bool Project::RemovePlatform(const gd::String& platformName) { bool Project::HasLayoutNamed(const gd::String& name) const { return (find_if(scenes.begin(), scenes.end(), - bind2nd(gd::LayoutHasName(), name)) != scenes.end()); + [&name](const std::unique_ptr& layout) { + return layout->GetName() == name; + }) != scenes.end()); } gd::Layout& Project::GetLayout(const gd::String& name) { return *(*find_if( - scenes.begin(), scenes.end(), bind2nd(gd::LayoutHasName(), name))); + scenes.begin(), scenes.end(), [&name](const std::unique_ptr& layout) { + return layout->GetName() == name; + })); } const gd::Layout& Project::GetLayout(const gd::String& name) const { return *(*find_if( - scenes.begin(), scenes.end(), bind2nd(gd::LayoutHasName(), name))); + scenes.begin(), scenes.end(), [&name](const std::unique_ptr& layout) { + return layout->GetName() == name; + })); } gd::Layout& Project::GetLayout(std::size_t index) { return *scenes[index]; } const gd::Layout& Project::GetLayout(std::size_t index) const { @@ -317,7 +323,9 @@ gd::Layout& Project::InsertLayout(const gd::Layout& layout, void Project::RemoveLayout(const gd::String& name) { std::vector >::iterator scene = - find_if(scenes.begin(), scenes.end(), bind2nd(gd::LayoutHasName(), name)); + find_if(scenes.begin(), scenes.end(), [&name](const std::unique_ptr& layout) { + return layout->GetName() == name; + }); if (scene == scenes.end()) return; scenes.erase(scene); @@ -326,19 +334,24 @@ void Project::RemoveLayout(const gd::String& name) { bool Project::HasExternalEventsNamed(const gd::String& name) const { return (find_if(externalEvents.begin(), externalEvents.end(), - bind2nd(gd::ExternalEventsHasName(), name)) != - externalEvents.end()); + [&name](const std::unique_ptr& externalEvents) { + return externalEvents->GetName() == name; + }) != externalEvents.end()); } gd::ExternalEvents& Project::GetExternalEvents(const gd::String& name) { return *(*find_if(externalEvents.begin(), externalEvents.end(), - bind2nd(gd::ExternalEventsHasName(), name))); + [&name](const std::unique_ptr& externalEvents) { + return externalEvents->GetName() == name; + })); } const gd::ExternalEvents& Project::GetExternalEvents( const gd::String& name) const { return *(*find_if(externalEvents.begin(), externalEvents.end(), - bind2nd(gd::ExternalEventsHasName(), name))); + [&name](const std::unique_ptr& externalEvents) { + return externalEvents->GetName() == name; + })); } gd::ExternalEvents& Project::GetExternalEvents(std::size_t index) { return *externalEvents[index]; @@ -382,7 +395,9 @@ void Project::RemoveExternalEvents(const gd::String& name) { std::vector >::iterator events = find_if(externalEvents.begin(), externalEvents.end(), - bind2nd(gd::ExternalEventsHasName(), name)); + [&name](const std::unique_ptr& externalEvents) { + return externalEvents->GetName() == name; + }); if (events == externalEvents.end()) return; externalEvents.erase(events); @@ -448,19 +463,24 @@ void Project::SwapExternalLayouts(std::size_t first, std::size_t second) { bool Project::HasExternalLayoutNamed(const gd::String& name) const { return (find_if(externalLayouts.begin(), externalLayouts.end(), - bind2nd(gd::ExternalLayoutHasName(), name)) != - externalLayouts.end()); + [&name](const std::unique_ptr& externalLayout) { + return externalLayout->GetName() == name; + }) != externalLayouts.end()); } gd::ExternalLayout& Project::GetExternalLayout(const gd::String& name) { return *(*find_if(externalLayouts.begin(), externalLayouts.end(), - bind2nd(gd::ExternalLayoutHasName(), name))); + [&name](const std::unique_ptr& externalLayout) { + return externalLayout->GetName() == name; + })); } const gd::ExternalLayout& Project::GetExternalLayout( const gd::String& name) const { return *(*find_if(externalLayouts.begin(), externalLayouts.end(), - bind2nd(gd::ExternalLayoutHasName(), name))); + [&name](const std::unique_ptr& externalLayout) { + return externalLayout->GetName() == name; + })); } gd::ExternalLayout& Project::GetExternalLayout(std::size_t index) { return *externalLayouts[index]; @@ -504,7 +524,9 @@ void Project::RemoveExternalLayout(const gd::String& name) { std::vector >::iterator externalLayout = find_if(externalLayouts.begin(), externalLayouts.end(), - bind2nd(gd::ExternalLayoutHasName(), name)); + [&name](const std::unique_ptr& externalLayout) { + return externalLayout->GetName() == name; + }); if (externalLayout == externalLayouts.end()) return; externalLayouts.erase(externalLayout); @@ -1076,7 +1098,9 @@ bool Project::HasSourceFile(gd::String name, gd::String language) const { vector >::const_iterator sourceFile = find_if(externalSourceFiles.begin(), externalSourceFiles.end(), - bind2nd(gd::ExternalSourceFileHasName(), name)); + [&name](const std::unique_ptr& sourceFile) { + return sourceFile->GetFileName() == name; + }); if (sourceFile == externalSourceFiles.end()) return false; @@ -1086,20 +1110,26 @@ bool Project::HasSourceFile(gd::String name, gd::String language) const { gd::SourceFile& Project::GetSourceFile(const gd::String& name) { return *(*find_if(externalSourceFiles.begin(), externalSourceFiles.end(), - bind2nd(gd::ExternalSourceFileHasName(), name))); + [&name](const std::unique_ptr& sourceFile) { + return sourceFile->GetFileName() == name; + })); } const gd::SourceFile& Project::GetSourceFile(const gd::String& name) const { return *(*find_if(externalSourceFiles.begin(), externalSourceFiles.end(), - bind2nd(gd::ExternalSourceFileHasName(), name))); + [&name](const std::unique_ptr& sourceFile) { + return sourceFile->GetFileName() == name; + })); } void Project::RemoveSourceFile(const gd::String& name) { std::vector >::iterator sourceFile = find_if(externalSourceFiles.begin(), externalSourceFiles.end(), - bind2nd(gd::ExternalSourceFileHasName(), name)); + [&name](const std::unique_ptr& sourceFile) { + return sourceFile->GetFileName() == name; + }); if (sourceFile == externalSourceFiles.end()) return; externalSourceFiles.erase(sourceFile); diff --git a/Core/GDCore/Project/SourceFile.h b/Core/GDCore/Project/SourceFile.h index 25bd9f9ad0..bf01f99ecb 100644 --- a/Core/GDCore/Project/SourceFile.h +++ b/Core/GDCore/Project/SourceFile.h @@ -87,20 +87,6 @@ class GD_CORE_API SourceFile { ///< SetAssociatedEvent. }; -//"Tool" Functions - -/** - * Functor testing Source Files name - */ -struct ExternalSourceFileHasName - : public std:: - binary_function, gd::String, bool> { - bool operator()(const std::unique_ptr& externalEvents, - gd::String name) const { - return externalEvents->GetFileName() == name; - } -}; - } // namespace gd #endif // SOURCEFILE_H