diff options
Diffstat (limited to 'Source/cmList.h')
-rw-r--r-- | Source/cmList.h | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/Source/cmList.h b/Source/cmList.h index d994ad3..8a1cb8e 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 |