From 4afe6c26c66556827e6089982c49b8dea3a2efcb Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 17 Feb 2015 22:04:25 +0100 Subject: [PATCH] cmAlgorithms: Add cmReverseRange adaptor. Use it to implement list(REVERSE). --- Source/cmAlgorithms.h | 8 ++++++++ Source/cmListCommand.cxx | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index d88de1ed3..b9bd67b57 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -302,4 +302,12 @@ typename Range::const_iterator cmFindNot(Range const& r, T const& t) std::bind1st(std::not_equal_to(), t)); } +template +ContainerAlgorithms::Range +cmReverseRange(Range const& range) +{ + return ContainerAlgorithms::Range( + range.rbegin(), range.rend()); +} + #endif diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 0c6adfd11..17617aae8 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -390,8 +390,7 @@ bool cmListCommand return false; } - std::reverse(varArgsExpanded.begin(), varArgsExpanded.end()); - std::string value = cmJoin(varArgsExpanded, ";"); + std::string value = cmJoin(cmReverseRange(varArgsExpanded), ";"); this->Makefile->AddDefinition(listName, value.c_str()); return true;