From dfed28c3073947cf6b77a53a6bab06285ff04a11 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 5 Apr 2018 12:25:02 -0400 Subject: [PATCH] make ninja build with -std=c++17 Ninja is supposed to be able to build as C++98 so it can run on old systems, but it should also be possible to optionally build it with newer dialects. --- src/build.cc | 7 ++++++- src/build.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/build.cc b/src/build.cc index 61ef0e849a..52396374d3 100644 --- a/src/build.cc +++ b/src/build.cc @@ -441,7 +441,12 @@ bool Plan::CleanNode(DependencyScan* scan, Node* node, string* err) { vector::iterator begin = (*oe)->inputs_.begin(), end = (*oe)->inputs_.end() - (*oe)->order_only_deps_; - if (find_if(begin, end, mem_fun(&Node::dirty)) == end) { +#if __cplusplus < 201703L +#define MEM_FN mem_fun +#else +#define MEM_FN mem_fn // mem_fun was removed in C++17. +#endif + if (find_if(begin, end, MEM_FN(&Node::dirty)) == end) { // Recompute most_recent_input. Node* most_recent_input = NULL; for (vector::iterator i = begin; i != end; ++i) { diff --git a/src/build.h b/src/build.h index 43786f1c92..e38719c4cd 100644 --- a/src/build.h +++ b/src/build.h @@ -178,7 +178,11 @@ struct Builder { State* state_; const BuildConfig& config_; Plan plan_; +#if __cplusplus < 201703L auto_ptr command_runner_; +#else + unique_ptr command_runner_; // auto_ptr was removed in C++17. +#endif BuildStatus* status_; private: