summaryrefslogtreecommitdiff
path: root/Source/cmList.h
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2023-04-17 12:32:18 +0200
committerMarc Chevrier <marc.chevrier@gmail.com>2023-04-23 14:48:36 +0200
commit51b0d45d9120d4bca5c7285d5e6b2f80db5a8310 (patch)
treed1ab83eb1e0e8e99e2a06dd413151187af77f6d4 /Source/cmList.h
parentc36f03bfecbb8c2331b66fec615c6d30917ae64d (diff)
downloadcmake-51b0d45d9120d4bca5c7285d5e6b2f80db5a8310.tar.gz
cmExpandList and cmExpandLists rely on cmList class
Diffstat (limited to 'Source/cmList.h')
-rw-r--r--Source/cmList.h56
1 files changed, 53 insertions, 3 deletions
diff --git a/Source/cmList.h b/Source/cmList.h
index d994ad3890..8a1cb8e992 100644
--- a/Source/cmList.h
+++ b/Source/cmList.h
@@ -16,6 +16,8 @@
#include <vector>
#include <cm/string_view>
+#include <cm/type_traits>
+#include <cmext/iterator>
#include "cmValue.h"
@@ -1177,6 +1179,13 @@ inline std::vector<std::string>& operator+=(std::vector<std::string>& l,
return l;
}
+namespace std {
+inline void swap(cmList& lhs, cmList& rhs) noexcept
+{
+ lhs.swap(rhs);
+}
+} // namespace std
+
namespace cm {
inline void erase(cmList& list, const std::string& value)
{
@@ -1188,11 +1197,52 @@ inline void erase_if(cmList& list, Predicate pred)
{
list.erase(std::remove_if(list.begin(), list.end(), pred), list.end());
}
+
+//
+// Provide a special implementation of cm::append because, in this case,
+// expansion must not be applied to the inserted elements
+//
+#if defined(__SUNPRO_CC) && defined(__sparc)
+// Oracle DeveloperStudio C++ compiler on Solaris/Sparc fails to compile
+// templates with constraints.
+// So, on this platform, use only simple templates.
+template <typename InputIt,
+ cm::enable_if_t<cm::is_input_iterator<InputIt>::value, int> = 0>
+void append(cmList& v, InputIt first, InputIt last)
+{
+ v.append(first, last, cmList::ExpandElements::No);
}
-namespace srd {
-inline void swap(cmList& lhs, cmList& rhs) noexcept
+template <typename Range,
+ cm::enable_if_t<cm::is_input_range<Range>::value, int> = 0>
+void append(cmList& v, Range const& r)
{
- lhs.swap(rhs);
+ v.append(r.begin(), r.end(), cmList::ExpandElements::No);
+}
+
+#else
+
+template <
+ typename InputIt,
+ cm::enable_if_t<
+ cm::is_input_iterator<InputIt>::value &&
+ std::is_convertible<typename std::iterator_traits<InputIt>::value_type,
+ cmList::value_type>::value,
+ int> = 0>
+void append(cmList& v, InputIt first, InputIt last)
+{
+ v.append(first, last, cmList::ExpandElements::No);
}
+
+template <typename Range,
+ cm::enable_if_t<cm::is_input_range<Range>::value &&
+ std::is_convertible<typename Range::value_type,
+ cmList::value_type>::value,
+ int> = 0>
+void append(cmList& v, Range const& r)
+{
+ v.append(r.begin(), r.end(), cmList::ExpandElements::No);
}
+#endif
+
+} // namespace cm