浏览代码

cmList class: various enhancements

Marc Chevrier 2 年之前
父节点
当前提交
87fe031a07

+ 6 - 6
Source/CPack/IFW/cmCPackIFWCommon.cxx

@@ -80,15 +80,15 @@ void cmCPackIFWCommon::ExpandListArgument(
     return;
     return;
   }
   }
 
 
-  cmList::index_type i = 0;
-  std::size_t c = args.size();
+  cmList::size_type i = 0;
+  auto c = args.size();
   if (c % 2) {
   if (c % 2) {
     argsOut[""] = args[i];
     argsOut[""] = args[i];
     ++i;
     ++i;
   }
   }
 
 
   --c;
   --c;
-  for (; i < static_cast<cmList::index_type>(c); i += 2) {
+  for (; i < c; i += 2) {
     argsOut[args[i]] = args[i + 1];
     argsOut[args[i]] = args[i + 1];
   }
   }
 }
 }
@@ -101,15 +101,15 @@ void cmCPackIFWCommon::ExpandListArgument(
     return;
     return;
   }
   }
 
 
-  cmList::index_type i = 0;
-  std::size_t c = args.size();
+  cmList::size_type i = 0;
+  auto c = args.size();
   if (c % 2) {
   if (c % 2) {
     argsOut.insert(std::pair<std::string, std::string>("", args[i]));
     argsOut.insert(std::pair<std::string, std::string>("", args[i]));
     ++i;
     ++i;
   }
   }
 
 
   --c;
   --c;
-  for (; i < static_cast<cmList::index_type>(c); i += 2) {
+  for (; i < c; i += 2) {
     argsOut.insert(std::pair<std::string, std::string>(args[i], args[i + 1]));
     argsOut.insert(std::pair<std::string, std::string>(args[i], args[i + 1]));
   }
   }
 }
 }

+ 16 - 11
Source/cmGeneratorExpressionNode.cxx

@@ -1157,12 +1157,17 @@ inline cmList GetList(std::string const& list)
   return list.empty() ? cmList{} : cmList{ list, cmList::EmptyElements::Yes };
   return list.empty() ? cmList{} : cmList{ list, cmList::EmptyElements::Yes };
 }
 }
 
 
-bool GetNumericArgument(const std::string& arg, int& value)
+bool GetNumericArgument(const std::string& arg, cmList::index_type& value)
 {
 {
   try {
   try {
     std::size_t pos;
     std::size_t pos;
 
 
-    value = std::stoi(arg, &pos);
+    if (sizeof(cmList::index_type) == sizeof(long)) {
+      value = std::stol(arg, &pos);
+    } else {
+      value = std::stoll(arg, &pos);
+    }
+
     if (pos != arg.length()) {
     if (pos != arg.length()) {
       // this is not a number
       // this is not a number
       return false;
       return false;
@@ -1176,7 +1181,7 @@ bool GetNumericArgument(const std::string& arg, int& value)
 
 
 bool GetNumericArguments(
 bool GetNumericArguments(
   cmGeneratorExpressionContext* ctx, const GeneratorExpressionContent* cnt,
   cmGeneratorExpressionContext* ctx, const GeneratorExpressionContent* cnt,
-  Arguments const& args, std::vector<int>& indexes,
+  Arguments const& args, std::vector<cmList::index_type>& indexes,
   cmList::ExpandElements expandElements = cmList::ExpandElements::No)
   cmList::ExpandElements expandElements = cmList::ExpandElements::No)
 {
 {
   using IndexRange = cmRange<Arguments::const_iterator>;
   using IndexRange = cmRange<Arguments::const_iterator>;
@@ -1188,7 +1193,7 @@ bool GetNumericArguments(
   }
   }
 
 
   for (auto const& value : arguments) {
   for (auto const& value : arguments) {
-    int index;
+    cmList::index_type index;
     if (!GetNumericArgument(value, index)) {
     if (!GetNumericArgument(value, index)) {
       reportError(ctx, cnt->GetOriginalExpression(),
       reportError(ctx, cnt->GetOriginalExpression(),
                   cmStrCat("index: \"", value, "\" is not a valid index"));
                   cmStrCat("index: \"", value, "\" is not a valid index"));
@@ -1242,7 +1247,7 @@ static const struct ListNode : public cmGeneratorExpressionNode
                 return std::string{};
                 return std::string{};
               }
               }
 
 
-              std::vector<int> indexes;
+              std::vector<cmList::index_type> indexes;
               if (!GetNumericArguments(ctx, cnt, args.advance(1), indexes,
               if (!GetNumericArguments(ctx, cnt, args.advance(1), indexes,
                                        cmList::ExpandElements::Yes)) {
                                        cmList::ExpandElements::Yes)) {
                 return std::string{};
                 return std::string{};
@@ -1273,7 +1278,7 @@ static const struct ListNode : public cmGeneratorExpressionNode
             if (CheckListParameters(ctx, cnt, "SUBLIST"_s, args, 3)) {
             if (CheckListParameters(ctx, cnt, "SUBLIST"_s, args, 3)) {
               auto list = GetList(args.front());
               auto list = GetList(args.front());
               if (!list.empty()) {
               if (!list.empty()) {
-                std::vector<int> indexes;
+                std::vector<cmList::index_type> indexes;
                 if (!GetNumericArguments(ctx, cnt, args.advance(1), indexes)) {
                 if (!GetNumericArguments(ctx, cnt, args.advance(1), indexes)) {
                   return std::string{};
                   return std::string{};
                 }
                 }
@@ -1322,7 +1327,7 @@ static const struct ListNode : public cmGeneratorExpressionNode
                                       false)) {
                                       false)) {
               auto list = args.front();
               auto list = args.front();
               args.advance(1);
               args.advance(1);
-              return cmList::append(args.begin(), args.end(), list);
+              return cmList::append(list, args.begin(), args.end());
             }
             }
             return std::string{};
             return std::string{};
           } },
           } },
@@ -1334,7 +1339,7 @@ static const struct ListNode : public cmGeneratorExpressionNode
                                       false)) {
                                       false)) {
               auto list = args.front();
               auto list = args.front();
               args.advance(1);
               args.advance(1);
-              return cmList::prepend(args.begin(), args.end(), list);
+              return cmList::prepend(list, args.begin(), args.end());
             }
             }
             return std::string{};
             return std::string{};
           } },
           } },
@@ -1344,7 +1349,7 @@ static const struct ListNode : public cmGeneratorExpressionNode
              Arguments& args) -> std::string {
              Arguments& args) -> std::string {
             if (CheckListParametersEx(ctx, cnt, "INSERT"_s, args.size(), 3,
             if (CheckListParametersEx(ctx, cnt, "INSERT"_s, args.size(), 3,
                                       false)) {
                                       false)) {
-              int index;
+              cmList::index_type index;
               if (!GetNumericArgument(args[1], index)) {
               if (!GetNumericArgument(args[1], index)) {
                 reportError(
                 reportError(
                   ctx, cnt->GetOriginalExpression(),
                   ctx, cnt->GetOriginalExpression(),
@@ -1419,7 +1424,7 @@ static const struct ListNode : public cmGeneratorExpressionNode
             if (CheckListParametersEx(ctx, cnt, "REMOVE_AT"_s, args.size(), 2,
             if (CheckListParametersEx(ctx, cnt, "REMOVE_AT"_s, args.size(), 2,
                                       false)) {
                                       false)) {
               auto list = GetList(args.front());
               auto list = GetList(args.front());
-              std::vector<int> indexes;
+              std::vector<cmList::index_type> indexes;
               if (!GetNumericArguments(ctx, cnt, args.advance(1), indexes,
               if (!GetNumericArguments(ctx, cnt, args.advance(1), indexes,
                                        cmList::ExpandElements::Yes)) {
                                        cmList::ExpandElements::Yes)) {
                 return std::string{};
                 return std::string{};
@@ -1575,7 +1580,7 @@ static const struct ListNode : public cmGeneratorExpressionNode
                       while (!args.empty()) {
                       while (!args.empty()) {
                         cmList indexList{ args.front() };
                         cmList indexList{ args.front() };
                         for (auto const& index : indexList) {
                         for (auto const& index : indexList) {
-                          int value;
+                          cmList::index_type value;
 
 
                           if (!GetNumericArgument(index, value)) {
                           if (!GetNumericArgument(index, value)) {
                             // this is not a number, stop processing
                             // this is not a number, stop processing

+ 16 - 13
Source/cmList.cxx

@@ -287,18 +287,20 @@ protected:
     : TransformSelector(std::move(tag))
     : TransformSelector(std::move(tag))
   {
   {
   }
   }
-  TransformSelectorIndexes(std::string&& tag, std::vector<int> const& indexes)
+  TransformSelectorIndexes(std::string&& tag,
+                           std::vector<index_type> const& indexes)
     : TransformSelector(std::move(tag))
     : TransformSelector(std::move(tag))
     , Indexes(indexes)
     , Indexes(indexes)
   {
   {
   }
   }
-  TransformSelectorIndexes(std::string&& tag, std::vector<int>&& indexes)
+  TransformSelectorIndexes(std::string&& tag,
+                           std::vector<index_type>&& indexes)
     : TransformSelector(std::move(tag))
     : TransformSelector(std::move(tag))
     , Indexes(indexes)
     , Indexes(indexes)
   {
   {
   }
   }
 
 
-  int NormalizeIndex(index_type index, std::size_t count)
+  index_type NormalizeIndex(index_type index, std::size_t count)
   {
   {
     if (index < 0) {
     if (index < 0) {
       index = static_cast<index_type>(count) + index;
       index = static_cast<index_type>(count) + index;
@@ -338,7 +340,7 @@ public:
 class TransformSelectorFor : public TransformSelectorIndexes
 class TransformSelectorFor : public TransformSelectorIndexes
 {
 {
 public:
 public:
-  TransformSelectorFor(int start, int stop, int step)
+  TransformSelectorFor(index_type start, index_type stop, index_type step)
     : TransformSelectorIndexes("FOR")
     : TransformSelectorIndexes("FOR")
     , Start(start)
     , Start(start)
     , Stop(stop)
     , Stop(stop)
@@ -369,7 +371,7 @@ public:
     auto start = this->Start;
     auto start = this->Start;
     auto step = this->Step;
     auto step = this->Step;
     std::generate(this->Indexes.begin(), this->Indexes.end(),
     std::generate(this->Indexes.begin(), this->Indexes.end(),
-                  [&start, step]() -> int {
+                  [&start, step]() -> index_type {
                     auto r = start;
                     auto r = start;
                     start += step;
                     start += step;
                     return r;
                     return r;
@@ -805,7 +807,7 @@ std::string cmList::join(cm::string_view glue) const
   return cmJoin(this->Values, glue);
   return cmJoin(this->Values, glue);
 }
 }
 
 
-std::string& cmList::append(cm::string_view value, std::string& list)
+std::string& cmList::append(std::string& list, cm::string_view value)
 {
 {
   if (list.empty()) {
   if (list.empty()) {
     list = std::string(value);
     list = std::string(value);
@@ -816,7 +818,7 @@ std::string& cmList::append(cm::string_view value, std::string& list)
   return list;
   return list;
 }
 }
 
 
-std::string& cmList::prepend(cm::string_view value, std::string& list)
+std::string& cmList::prepend(std::string& list, cm::string_view value)
 {
 {
   if (list.empty()) {
   if (list.empty()) {
     list = std::string(value);
     list = std::string(value);
@@ -884,7 +886,7 @@ cmList cmList::GetItems(std::vector<index_type>&& indexes) const
   cmList listItems;
   cmList listItems;
 
 
   for (auto index : indexes) {
   for (auto index : indexes) {
-    listItems.emplace_back(this->at(index));
+    listItems.emplace_back(this->get_item(index));
   }
   }
 
 
   return listItems;
   return listItems;
@@ -898,9 +900,10 @@ cmList& cmList::RemoveItems(std::vector<index_type>&& indexes)
 
 
   // compute all indexes
   // compute all indexes
   std::vector<size_type> idx(indexes.size());
   std::vector<size_type> idx(indexes.size());
-  std::transform(
-    indexes.cbegin(), indexes.cend(), idx.begin(),
-    [this](const index_type& index) { return this->ComputeIndex(index); });
+  std::transform(indexes.cbegin(), indexes.cend(), idx.begin(),
+                 [this](const index_type& index) -> size_type {
+                   return this->ComputeIndex(index);
+                 });
 
 
   std::sort(idx.begin(), idx.end(),
   std::sort(idx.begin(), idx.end(),
             [](size_type l, size_type r) { return l > r; });
             [](size_type l, size_type r) { return l > r; });
@@ -927,8 +930,8 @@ cmList& cmList::RemoveItems(std::vector<std::string>&& items)
 }
 }
 
 
 cmList::container_type::iterator cmList::Insert(
 cmList::container_type::iterator cmList::Insert(
-  container_type::const_iterator pos, std::string&& value,
-  container_type& container, ExpandElements expandElements,
+  container_type& container, container_type::const_iterator pos,
+  std::string&& value, ExpandElements expandElements,
   EmptyElements emptyElements)
   EmptyElements emptyElements)
 {
 {
   auto delta = std::distance(container.cbegin(), pos);
   auto delta = std::distance(container.cbegin(), pos);

+ 170 - 85
Source/cmList.h

@@ -6,6 +6,7 @@
 #include "cmConfigure.h" // IWYU pragma: keep
 #include "cmConfigure.h" // IWYU pragma: keep
 
 
 #include <algorithm>
 #include <algorithm>
+#include <cstdint>
 #include <initializer_list>
 #include <initializer_list>
 #include <iterator>
 #include <iterator>
 #include <memory>
 #include <memory>
@@ -29,8 +30,10 @@
  * expanded. The expansion can be controlled by the cmList::ExpandElements
  * expanded. The expansion can be controlled by the cmList::ExpandElements
  * option.
  * option.
  *
  *
- * There is an exception to this rule. The following methods do not expand
- * their argument: cmList::push_back, cmList::emplace and cmList::emplace_back.
+ * There ate some exceptions to this rule:
+ *  * When the input argument is a cmList instance, the value is not expanded.
+ *  * The following methods do not expand their argument: cmList::push_back,
+ *    cmList::emplace and cmList::emplace_back.
  */
  */
 
 
 class cmList
 class cmList
@@ -40,7 +43,7 @@ public:
 
 
   using value_type = container_type::value_type;
   using value_type = container_type::value_type;
   using allocator_type = container_type::allocator_type;
   using allocator_type = container_type::allocator_type;
-  using index_type = int;
+  using index_type = std::intptr_t;
   using size_type = container_type::size_type;
   using size_type = container_type::size_type;
   using difference_type = container_type::difference_type;
   using difference_type = container_type::difference_type;
   using reference = container_type::reference;
   using reference = container_type::reference;
@@ -76,8 +79,18 @@ public:
     this->assign(value, expandElements, emptyElements);
     this->assign(value, expandElements, emptyElements);
   }
   }
   cmList(cm::string_view value, EmptyElements emptyElements)
   cmList(cm::string_view value, EmptyElements emptyElements)
+    : cmList(value, ExpandElements::Yes, emptyElements)
+  {
+  }
+  cmList(std::string const& value,
+         ExpandElements expandElements = ExpandElements::Yes,
+         EmptyElements emptyElements = EmptyElements::No)
+  {
+    this->assign(value, expandElements, emptyElements);
+  }
+  cmList(std::string const& value, EmptyElements emptyElements)
+    : cmList(value, ExpandElements::Yes, emptyElements)
   {
   {
-    this->assign(value, ExpandElements::Yes, emptyElements);
   }
   }
   cmList(cmValue list, ExpandElements expandElements = ExpandElements::Yes,
   cmList(cmValue list, ExpandElements expandElements = ExpandElements::Yes,
          EmptyElements emptyElements = EmptyElements::No)
          EmptyElements emptyElements = EmptyElements::No)
@@ -137,6 +150,11 @@ public:
     this->assign(value);
     this->assign(value);
     return *this;
     return *this;
   }
   }
+  cmList& operator=(std::string const& value)
+  {
+    this->assign(value);
+    return *this;
+  }
   cmList& operator=(cmValue value)
   cmList& operator=(cmValue value)
   {
   {
     if (value) {
     if (value) {
@@ -177,6 +195,17 @@ public:
   {
   {
     this->assign(value, ExpandElements::Yes, emptyElements);
     this->assign(value, ExpandElements::Yes, emptyElements);
   }
   }
+  void assign(std::string const& value,
+              ExpandElements expandElements = ExpandElements::Yes,
+              EmptyElements emptyElements = EmptyElements::No)
+  {
+    this->clear();
+    this->append(value, expandElements, emptyElements);
+  }
+  void assign(std::string const& value, EmptyElements emptyElements)
+  {
+    this->assign(value, ExpandElements::Yes, emptyElements);
+  }
   void assign(cmValue value,
   void assign(cmValue value,
               ExpandElements expandElements = ExpandElements::Yes,
               ExpandElements expandElements = ExpandElements::Yes,
               EmptyElements emptyElements = EmptyElements::No)
               EmptyElements emptyElements = EmptyElements::No)
@@ -206,17 +235,17 @@ public:
     this->assign(first, last, ExpandElements::Yes, emptyElements);
     this->assign(first, last, ExpandElements::Yes, emptyElements);
   }
   }
   void assign(const cmList& init,
   void assign(const cmList& init,
-              ExpandElements expandElements = ExpandElements::Yes,
+              ExpandElements expandElements = ExpandElements::No,
               EmptyElements emptyElements = EmptyElements::No)
               EmptyElements emptyElements = EmptyElements::No)
   {
   {
     this->assign(init.begin(), init.end(), expandElements, emptyElements);
     this->assign(init.begin(), init.end(), expandElements, emptyElements);
   }
   }
   void assign(const cmList& init, EmptyElements emptyElements)
   void assign(const cmList& init, EmptyElements emptyElements)
   {
   {
-    this->assign(init, ExpandElements::Yes, emptyElements);
+    this->assign(init, ExpandElements::No, emptyElements);
   }
   }
   void assign(cmList&& init,
   void assign(cmList&& init,
-              ExpandElements expandElements = ExpandElements::Yes,
+              ExpandElements expandElements = ExpandElements::No,
               EmptyElements emptyElements = EmptyElements::No)
               EmptyElements emptyElements = EmptyElements::No)
   {
   {
     this->assign(std::make_move_iterator(init.begin()),
     this->assign(std::make_move_iterator(init.begin()),
@@ -226,7 +255,7 @@ public:
   }
   }
   void assign(cmList&& init, EmptyElements emptyElements)
   void assign(cmList&& init, EmptyElements emptyElements)
   {
   {
-    this->assign(std::move(init), ExpandElements::Yes, emptyElements);
+    this->assign(std::move(init), ExpandElements::No, emptyElements);
   }
   }
   void assign(const container_type& init,
   void assign(const container_type& init,
               ExpandElements expandElements = ExpandElements::Yes,
               ExpandElements expandElements = ExpandElements::Yes,
@@ -267,24 +296,21 @@ public:
   operator container_type&&() && noexcept { return std::move(this->Values); }
   operator container_type&&() && noexcept { return std::move(this->Values); }
 
 
   // Element access
   // Element access
-  reference at(index_type pos)
+  reference at(size_type pos) { return this->Values.at(pos); }
+  const_reference at(size_type pos) const { return this->Values.at(pos); }
+
+  reference operator[](size_type pos) { return this->Values[pos]; }
+  const_reference operator[](size_type pos) const { return this->Values[pos]; }
+
+  reference get_item(index_type pos)
   {
   {
     return this->Values.at(this->ComputeIndex(pos));
     return this->Values.at(this->ComputeIndex(pos));
   }
   }
-  const_reference at(index_type pos) const
+  const_reference get_item(index_type pos) const
   {
   {
     return this->Values.at(this->ComputeIndex(pos));
     return this->Values.at(this->ComputeIndex(pos));
   }
   }
 
 
-  reference operator[](index_type pos)
-  {
-    return this->Values[this->ComputeIndex(pos, false)];
-  }
-  const_reference operator[](index_type pos) const
-  {
-    return this->Values[this->ComputeIndex(pos, false)];
-  }
-
   reference front() { return this->Values.front(); }
   reference front() { return this->Values.front(); }
   const_reference front() const { return this->Values.front(); }
   const_reference front() const { return this->Values.front(); }
 
 
@@ -363,7 +389,7 @@ public:
                   ExpandElements expandElements = ExpandElements::Yes,
                   ExpandElements expandElements = ExpandElements::Yes,
                   EmptyElements emptyElements = EmptyElements::No)
                   EmptyElements emptyElements = EmptyElements::No)
   {
   {
-    return cmList::Insert(pos, std::string(value), this->Values,
+    return cmList::Insert(this->Values, pos, std::string(value),
                           expandElements, emptyElements);
                           expandElements, emptyElements);
   }
   }
   iterator insert(const_iterator pos, cm::string_view value,
   iterator insert(const_iterator pos, cm::string_view value,
@@ -371,6 +397,18 @@ public:
   {
   {
     return this->insert(pos, value, ExpandElements::Yes, emptyElements);
     return this->insert(pos, value, ExpandElements::Yes, emptyElements);
   }
   }
+  iterator insert(const_iterator pos, std::string const& value,
+                  ExpandElements expandElements = ExpandElements::Yes,
+                  EmptyElements emptyElements = EmptyElements::No)
+  {
+    return cmList::Insert(this->Values, pos, value, expandElements,
+                          emptyElements);
+  }
+  iterator insert(const_iterator pos, std::string const& value,
+                  EmptyElements emptyElements)
+  {
+    return this->insert(pos, value, ExpandElements::Yes, emptyElements);
+  }
   iterator insert(const_iterator pos, cmValue value,
   iterator insert(const_iterator pos, cmValue value,
                   ExpandElements expandElements = ExpandElements::Yes,
                   ExpandElements expandElements = ExpandElements::Yes,
                   EmptyElements emptyElements = EmptyElements::No)
                   EmptyElements emptyElements = EmptyElements::No)
@@ -392,7 +430,7 @@ public:
                   ExpandElements expandElements = ExpandElements::Yes,
                   ExpandElements expandElements = ExpandElements::Yes,
                   EmptyElements emptyElements = EmptyElements::No)
                   EmptyElements emptyElements = EmptyElements::No)
   {
   {
-    return cmList::Insert(pos, first, last, this->Values, expandElements,
+    return cmList::Insert(this->Values, pos, first, last, expandElements,
                           emptyElements);
                           emptyElements);
   }
   }
   template <typename InputIterator>
   template <typename InputIterator>
@@ -402,7 +440,7 @@ public:
     return this->insert(pos, first, last, ExpandElements::Yes, emptyElements);
     return this->insert(pos, first, last, ExpandElements::Yes, emptyElements);
   }
   }
   iterator insert(const_iterator pos, const cmList& values,
   iterator insert(const_iterator pos, const cmList& values,
-                  ExpandElements expandElements = ExpandElements::Yes,
+                  ExpandElements expandElements = ExpandElements::No,
                   EmptyElements emptyElements = EmptyElements::No)
                   EmptyElements emptyElements = EmptyElements::No)
   {
   {
     return this->insert(pos, values.begin(), values.end(), expandElements,
     return this->insert(pos, values.begin(), values.end(), expandElements,
@@ -411,10 +449,10 @@ public:
   iterator insert(const_iterator pos, const cmList& values,
   iterator insert(const_iterator pos, const cmList& values,
                   EmptyElements emptyElements)
                   EmptyElements emptyElements)
   {
   {
-    return this->insert(pos, values, ExpandElements::Yes, emptyElements);
+    return this->insert(pos, values, ExpandElements::No, emptyElements);
   }
   }
   iterator insert(const_iterator pos, cmList&& values,
   iterator insert(const_iterator pos, cmList&& values,
-                  ExpandElements expandElements = ExpandElements::Yes,
+                  ExpandElements expandElements = ExpandElements::No,
                   EmptyElements emptyElements = EmptyElements::No)
                   EmptyElements emptyElements = EmptyElements::No)
   {
   {
     auto result = this->insert(pos, std::make_move_iterator(values.begin()),
     auto result = this->insert(pos, std::make_move_iterator(values.begin()),
@@ -427,7 +465,7 @@ public:
   iterator insert(const_iterator pos, cmList&& values,
   iterator insert(const_iterator pos, cmList&& values,
                   EmptyElements emptyElements)
                   EmptyElements emptyElements)
   {
   {
-    return this->insert(pos, std::move(values), ExpandElements::Yes,
+    return this->insert(pos, std::move(values), ExpandElements::No,
                         emptyElements);
                         emptyElements);
   }
   }
   iterator insert(const_iterator pos, const container_type& values,
   iterator insert(const_iterator pos, const container_type& values,
@@ -474,6 +512,16 @@ public:
   {
   {
     return this->append(value, ExpandElements::Yes, emptyElements);
     return this->append(value, ExpandElements::Yes, emptyElements);
   }
   }
+  iterator append(std::string const& value,
+                  ExpandElements expandElements = ExpandElements::Yes,
+                  EmptyElements emptyElements = EmptyElements::No)
+  {
+    return this->insert(this->cend(), value, expandElements, emptyElements);
+  }
+  iterator append(std::string const& value, EmptyElements emptyElements)
+  {
+    return this->append(value, ExpandElements::Yes, emptyElements);
+  }
   iterator append(cmValue value,
   iterator append(cmValue value,
                   ExpandElements expandElements = ExpandElements::Yes,
                   ExpandElements expandElements = ExpandElements::Yes,
                   EmptyElements emptyElements = EmptyElements::No)
                   EmptyElements emptyElements = EmptyElements::No)
@@ -503,7 +551,7 @@ public:
     return this->append(first, last, ExpandElements::Yes, emptyElements);
     return this->append(first, last, ExpandElements::Yes, emptyElements);
   }
   }
   iterator append(const cmList& values,
   iterator append(const cmList& values,
-                  ExpandElements expandElements = ExpandElements::Yes,
+                  ExpandElements expandElements = ExpandElements::No,
                   EmptyElements emptyElements = EmptyElements::No)
                   EmptyElements emptyElements = EmptyElements::No)
   {
   {
     return this->append(values.begin(), values.end(), expandElements,
     return this->append(values.begin(), values.end(), expandElements,
@@ -511,10 +559,10 @@ public:
   }
   }
   iterator append(const cmList& values, EmptyElements emptyElements)
   iterator append(const cmList& values, EmptyElements emptyElements)
   {
   {
-    return this->append(values, ExpandElements::Yes, emptyElements);
+    return this->append(values, ExpandElements::No, emptyElements);
   }
   }
   iterator append(cmList&& values,
   iterator append(cmList&& values,
-                  ExpandElements expandElements = ExpandElements::Yes,
+                  ExpandElements expandElements = ExpandElements::No,
                   EmptyElements emptyElements = EmptyElements::No)
                   EmptyElements emptyElements = EmptyElements::No)
   {
   {
     auto result = this->append(std::make_move_iterator(values.begin()),
     auto result = this->append(std::make_move_iterator(values.begin()),
@@ -526,7 +574,7 @@ public:
   }
   }
   iterator append(cmList&& values, EmptyElements emptyElements)
   iterator append(cmList&& values, EmptyElements emptyElements)
   {
   {
-    return this->append(std::move(values), ExpandElements::Yes, emptyElements);
+    return this->append(std::move(values), ExpandElements::No, emptyElements);
   }
   }
   iterator append(const container_type& values,
   iterator append(const container_type& values,
                   ExpandElements expandElements = ExpandElements::Yes,
                   ExpandElements expandElements = ExpandElements::Yes,
@@ -569,6 +617,16 @@ public:
   {
   {
     return this->prepend(value, ExpandElements::Yes, emptyElements);
     return this->prepend(value, ExpandElements::Yes, emptyElements);
   }
   }
+  iterator prepend(std::string const& value,
+                   ExpandElements expandElements = ExpandElements::Yes,
+                   EmptyElements emptyElements = EmptyElements::No)
+  {
+    return this->insert(this->cbegin(), value, expandElements, emptyElements);
+  }
+  iterator prepend(std::string const& value, EmptyElements emptyElements)
+  {
+    return this->prepend(value, ExpandElements::Yes, emptyElements);
+  }
   iterator prepend(cmValue value,
   iterator prepend(cmValue value,
                    ExpandElements expandElements = ExpandElements::Yes,
                    ExpandElements expandElements = ExpandElements::Yes,
                    EmptyElements emptyElements = EmptyElements::No)
                    EmptyElements emptyElements = EmptyElements::No)
@@ -598,7 +656,7 @@ public:
     return this->prepend(first, last, ExpandElements::Yes, emptyElements);
     return this->prepend(first, last, ExpandElements::Yes, emptyElements);
   }
   }
   iterator prepend(const cmList& values,
   iterator prepend(const cmList& values,
-                   ExpandElements expandElements = ExpandElements::Yes,
+                   ExpandElements expandElements = ExpandElements::No,
                    EmptyElements emptyElements = EmptyElements::No)
                    EmptyElements emptyElements = EmptyElements::No)
   {
   {
     return this->prepend(values.begin(), values.end(), expandElements,
     return this->prepend(values.begin(), values.end(), expandElements,
@@ -606,10 +664,10 @@ public:
   }
   }
   iterator prepend(const cmList& values, EmptyElements emptyElements)
   iterator prepend(const cmList& values, EmptyElements emptyElements)
   {
   {
-    return this->prepend(values, ExpandElements::Yes, emptyElements);
+    return this->prepend(values, ExpandElements::No, emptyElements);
   }
   }
   iterator prepend(cmList&& values,
   iterator prepend(cmList&& values,
-                   ExpandElements expandElements = ExpandElements::Yes,
+                   ExpandElements expandElements = ExpandElements::No,
                    EmptyElements emptyElements = EmptyElements::No)
                    EmptyElements emptyElements = EmptyElements::No)
   {
   {
     auto result = this->prepend(std::make_move_iterator(values.begin()),
     auto result = this->prepend(std::make_move_iterator(values.begin()),
@@ -621,8 +679,7 @@ public:
   }
   }
   iterator prepend(cmList&& values, EmptyElements emptyElements)
   iterator prepend(cmList&& values, EmptyElements emptyElements)
   {
   {
-    return this->prepend(std::move(values), ExpandElements::Yes,
-                         emptyElements);
+    return this->prepend(std::move(values), ExpandElements::No, emptyElements);
   }
   }
   iterator prepend(const container_type& values,
   iterator prepend(const container_type& values,
                    ExpandElements expandElements = ExpandElements::Yes,
                    ExpandElements expandElements = ExpandElements::Yes,
@@ -656,6 +713,7 @@ public:
     return this->insert(this->cbegin(), ilist);
     return this->insert(this->cbegin(), ilist);
   }
   }
 
 
+  void push_back(std::string const& value) { this->Values.push_back(value); }
   void push_back(cm::string_view value)
   void push_back(cm::string_view value)
   {
   {
     this->Values.push_back(std::string{ value });
     this->Values.push_back(std::string{ value });
@@ -735,6 +793,8 @@ public:
 
 
   cmList& remove_duplicates();
   cmList& remove_duplicates();
 
 
+  void resize(size_type count) { this->Values.resize(count); }
+
   enum class FilterMode
   enum class FilterMode
   {
   {
     INCLUDE,
     INCLUDE,
@@ -882,46 +942,61 @@ public:
   // ==============
   // ==============
   // these methods can be used to store CMake list expansion directly in a
   // these methods can be used to store CMake list expansion directly in a
   // std::vector.
   // std::vector.
-  static void assign(cm::string_view value,
-                     std::vector<std::string>& container,
+  static void assign(std::vector<std::string>& container,
+                     cm::string_view value,
+                     EmptyElements emptyElements = EmptyElements::No)
+  {
+    container.clear();
+    cmList::append(container, value, emptyElements);
+  }
+  static void assign(std::vector<std::string>& container,
+                     std::string const& value,
                      EmptyElements emptyElements = EmptyElements::No)
                      EmptyElements emptyElements = EmptyElements::No)
   {
   {
     container.clear();
     container.clear();
-    cmList::append(value, container, emptyElements);
+    cmList::append(container, value, emptyElements);
   }
   }
-  static void assign(cmValue value, std::vector<std::string>& container,
+  static void assign(std::vector<std::string>& container, cmValue value,
                      EmptyElements emptyElements = EmptyElements::No)
                      EmptyElements emptyElements = EmptyElements::No)
   {
   {
     if (value) {
     if (value) {
-      cmList::assign(*value, container, emptyElements);
+      cmList::assign(container, *value, emptyElements);
     } else {
     } else {
       container.clear();
       container.clear();
     }
     }
   }
   }
   template <typename InputIterator>
   template <typename InputIterator>
-  static void assign(InputIterator first, InputIterator last,
-                     std::vector<std::string>& container,
+  static void assign(std::vector<std::string>& container, InputIterator first,
+                     InputIterator last,
                      EmptyElements emptyElements = EmptyElements::No)
                      EmptyElements emptyElements = EmptyElements::No)
   {
   {
     container.clear();
     container.clear();
-    cmList::append(first, last, container, emptyElements);
+    cmList::append(container, first, last, emptyElements);
   }
   }
 
 
   static std::vector<std::string>::iterator insert(
   static std::vector<std::string>::iterator insert(
-    std::vector<std::string>::const_iterator pos, cm::string_view value,
     std::vector<std::string>& container,
     std::vector<std::string>& container,
+    std::vector<std::string>::const_iterator pos, cm::string_view value,
     EmptyElements emptyElements = EmptyElements::No)
     EmptyElements emptyElements = EmptyElements::No)
   {
   {
-    return cmList::Insert(pos, std::string(value), container,
+    return cmList::Insert(container, pos, std::string(value),
                           ExpandElements::Yes, emptyElements);
                           ExpandElements::Yes, emptyElements);
   }
   }
   static std::vector<std::string>::iterator insert(
   static std::vector<std::string>::iterator insert(
-    std::vector<std::string>::const_iterator pos, cmValue value,
     std::vector<std::string>& container,
     std::vector<std::string>& container,
+    std::vector<std::string>::const_iterator pos, std::string const& value,
+    EmptyElements emptyElements = EmptyElements::No)
+  {
+    return cmList::Insert(container, pos, value, ExpandElements::Yes,
+                          emptyElements);
+  }
+  static std::vector<std::string>::iterator insert(
+    std::vector<std::string>& container,
+    std::vector<std::string>::const_iterator pos, cmValue value,
     EmptyElements emptyElements = EmptyElements::No)
     EmptyElements emptyElements = EmptyElements::No)
   {
   {
     if (value) {
     if (value) {
-      return cmList::insert(pos, *value, container, emptyElements);
+      return cmList::insert(container, pos, *value, emptyElements);
     }
     }
 
 
     auto delta = std::distance(container.cbegin(), pos);
     auto delta = std::distance(container.cbegin(), pos);
@@ -929,63 +1004,73 @@ public:
   }
   }
   template <typename InputIterator>
   template <typename InputIterator>
   static std::vector<std::string>::iterator insert(
   static std::vector<std::string>::iterator insert(
+    std::vector<std::string>& container,
     std::vector<std::string>::const_iterator pos, InputIterator first,
     std::vector<std::string>::const_iterator pos, InputIterator first,
-    InputIterator last, std::vector<std::string>& container,
-    EmptyElements emptyElements = EmptyElements::No)
+    InputIterator last, EmptyElements emptyElements = EmptyElements::No)
   {
   {
-    return cmList::Insert(pos, first, last, container, ExpandElements::Yes,
+    return cmList::Insert(container, pos, first, last, ExpandElements::Yes,
                           emptyElements);
                           emptyElements);
   }
   }
 
 
   static std::vector<std::string>::iterator append(
   static std::vector<std::string>::iterator append(
-    cm::string_view value, std::vector<std::string>& container,
+    std::vector<std::string>& container, cm::string_view value,
     EmptyElements emptyElements = EmptyElements::No)
     EmptyElements emptyElements = EmptyElements::No)
   {
   {
-    return cmList::insert(container.cend(), value, container, emptyElements);
+    return cmList::insert(container, container.cend(), value, emptyElements);
   }
   }
   static std::vector<std::string>::iterator append(
   static std::vector<std::string>::iterator append(
-    cmValue value, std::vector<std::string>& container,
+    std::vector<std::string>& container, std::string const& value,
+    EmptyElements emptyElements = EmptyElements::No)
+  {
+    return cmList::insert(container, container.cend(), value, emptyElements);
+  }
+  static std::vector<std::string>::iterator append(
+    std::vector<std::string>& container, cmValue value,
     EmptyElements emptyElements = EmptyElements::No)
     EmptyElements emptyElements = EmptyElements::No)
   {
   {
     if (value) {
     if (value) {
-      return cmList::append(*value, container, emptyElements);
+      return cmList::append(container, *value, emptyElements);
     }
     }
 
 
     return container.end();
     return container.end();
   }
   }
   template <typename InputIterator>
   template <typename InputIterator>
   static std::vector<std::string>::iterator append(
   static std::vector<std::string>::iterator append(
-    InputIterator first, InputIterator last,
-    std::vector<std::string>& container,
-    EmptyElements emptyElements = EmptyElements::No)
+    std::vector<std::string>& container, InputIterator first,
+    InputIterator last, EmptyElements emptyElements = EmptyElements::No)
   {
   {
-    return cmList::insert(container.cend(), first, last, container,
+    return cmList::insert(container, container.cend(), first, last,
                           emptyElements);
                           emptyElements);
   }
   }
 
 
   static std::vector<std::string>::iterator prepend(
   static std::vector<std::string>::iterator prepend(
-    cm::string_view value, std::vector<std::string>& container,
+    std::vector<std::string>& container, cm::string_view value,
     EmptyElements emptyElements = EmptyElements::No)
     EmptyElements emptyElements = EmptyElements::No)
   {
   {
-    return cmList::insert(container.cbegin(), value, container, emptyElements);
+    return cmList::insert(container, container.cbegin(), value, emptyElements);
   }
   }
   static std::vector<std::string>::iterator prepend(
   static std::vector<std::string>::iterator prepend(
-    cmValue value, std::vector<std::string>& container,
+    std::vector<std::string>& container, std::string const& value,
+    EmptyElements emptyElements = EmptyElements::No)
+  {
+    return cmList::insert(container, container.cbegin(), value, emptyElements);
+  }
+  static std::vector<std::string>::iterator prepend(
+    std::vector<std::string>& container, cmValue value,
     EmptyElements emptyElements = EmptyElements::No)
     EmptyElements emptyElements = EmptyElements::No)
   {
   {
     if (value) {
     if (value) {
-      return cmList::prepend(*value, container, emptyElements);
+      return cmList::prepend(container, *value, emptyElements);
     }
     }
 
 
     return container.begin();
     return container.begin();
   }
   }
   template <typename InputIterator>
   template <typename InputIterator>
   static std::vector<std::string>::iterator prepend(
   static std::vector<std::string>::iterator prepend(
-    InputIterator first, InputIterator last,
-    std::vector<std::string>& container,
-    EmptyElements emptyElements = EmptyElements::No)
+    std::vector<std::string>& container, InputIterator first,
+    InputIterator last, EmptyElements emptyElements = EmptyElements::No)
   {
   {
-    return cmList::insert(container.cbegin(), first, last, container,
+    return cmList::insert(container, container.cbegin(), first, last,
                           emptyElements);
                           emptyElements);
   }
   }
 
 
@@ -993,40 +1078,40 @@ public:
   // but without any intermediate expansion. So the operation is simply a
   // but without any intermediate expansion. So the operation is simply a
   // string concatenation with special handling for the CMake list item
   // string concatenation with special handling for the CMake list item
   // separator
   // separator
-  static std::string& append(cm::string_view value, std::string& list);
+  static std::string& append(std::string& list, cm::string_view value);
   template <typename InputIterator>
   template <typename InputIterator>
-  static std::string& append(InputIterator first, InputIterator last,
-                             std::string& list)
+  static std::string& append(std::string& list, InputIterator first,
+                             InputIterator last)
   {
   {
     if (first == last) {
     if (first == last) {
       return list;
       return list;
     }
     }
 
 
-    return cmList::append(cm::string_view{ std::accumulate(
+    return cmList::append(list,
+                          cm::string_view{ std::accumulate(
                             std::next(first), last, *first,
                             std::next(first), last, *first,
                             [](std::string a, const std::string& b) {
                             [](std::string a, const std::string& b) {
                               return std::move(a) +
                               return std::move(a) +
                                 std::string(cmList::element_separator) + b;
                                 std::string(cmList::element_separator) + b;
-                            }) },
-                          list);
+                            }) });
   }
   }
 
 
-  static std::string& prepend(cm::string_view value, std::string& list);
+  static std::string& prepend(std::string& list, cm::string_view value);
   template <typename InputIterator>
   template <typename InputIterator>
-  static std::string& prepend(InputIterator first, InputIterator last,
-                              std::string& list)
+  static std::string& prepend(std::string& list, InputIterator first,
+                              InputIterator last)
   {
   {
     if (first == last) {
     if (first == last) {
       return list;
       return list;
     }
     }
 
 
-    return cmList::prepend(cm::string_view{ std::accumulate(
+    return cmList::prepend(list,
+                           cm::string_view{ std::accumulate(
                              std::next(first), last, *first,
                              std::next(first), last, *first,
                              [](std::string a, const std::string& b) {
                              [](std::string a, const std::string& b) {
                                return std::move(a) +
                                return std::move(a) +
                                  std::string(cmList::element_separator) + b;
                                  std::string(cmList::element_separator) + b;
-                             }) },
-                           list);
+                             }) });
   }
   }
 
 
   // Non-members
   // Non-members
@@ -1049,26 +1134,26 @@ private:
   cmList& RemoveItems(std::vector<index_type>&& indexes);
   cmList& RemoveItems(std::vector<index_type>&& indexes);
   cmList& RemoveItems(std::vector<std::string>&& items);
   cmList& RemoveItems(std::vector<std::string>&& items);
 
 
-  static container_type::iterator Insert(container_type::const_iterator pos,
+  static container_type::iterator Insert(container_type& container,
+                                         container_type::const_iterator pos,
                                          std::string&& value,
                                          std::string&& value,
-                                         container_type& container,
                                          ExpandElements expandElements,
                                          ExpandElements expandElements,
                                          EmptyElements emptyElements);
                                          EmptyElements emptyElements);
-  static container_type::iterator Insert(container_type::const_iterator pos,
+  static container_type::iterator Insert(container_type& container,
+                                         container_type::const_iterator pos,
                                          const std::string& value,
                                          const std::string& value,
-                                         container_type& container,
                                          ExpandElements expandElements,
                                          ExpandElements expandElements,
                                          EmptyElements emptyElements)
                                          EmptyElements emptyElements)
   {
   {
     auto tmp = value;
     auto tmp = value;
-    return cmList::Insert(pos, std::move(tmp), container, expandElements,
+    return cmList::Insert(container, pos, std::move(tmp), expandElements,
                           emptyElements);
                           emptyElements);
   }
   }
   template <typename InputIterator>
   template <typename InputIterator>
-  static container_type::iterator Insert(container_type::const_iterator pos,
+  static container_type::iterator Insert(container_type& container,
+                                         container_type::const_iterator pos,
                                          InputIterator first,
                                          InputIterator first,
                                          InputIterator last,
                                          InputIterator last,
-                                         container_type& container,
                                          ExpandElements expandElements,
                                          ExpandElements expandElements,
                                          EmptyElements emptyElements)
                                          EmptyElements emptyElements)
   {
   {
@@ -1082,7 +1167,7 @@ private:
     if (expandElements == ExpandElements::Yes) {
     if (expandElements == ExpandElements::Yes) {
       for (; first != last; ++first) {
       for (; first != last; ++first) {
         auto size = container.size();
         auto size = container.size();
-        insertPos = cmList::Insert(insertPos, *first, container,
+        insertPos = cmList::Insert(container, insertPos, *first,
                                    expandElements, emptyElements);
                                    expandElements, emptyElements);
         insertPos += container.size() - size;
         insertPos += container.size() - size;
       }
       }

+ 2 - 2
Source/cmListCommand.cxx

@@ -205,7 +205,7 @@ bool HandleAppendCommand(std::vector<std::string> const& args,
   GetListString(listString, listName, makefile);
   GetListString(listString, listName, makefile);
 
 
   makefile.AddDefinition(
   makefile.AddDefinition(
-    listName, cmList::append(args.begin() + 2, args.end(), listString));
+    listName, cmList::append(listString, args.begin() + 2, args.end()));
   return true;
   return true;
 }
 }
 
 
@@ -226,7 +226,7 @@ bool HandlePrependCommand(std::vector<std::string> const& args,
   GetListString(listString, listName, makefile);
   GetListString(listString, listName, makefile);
 
 
   makefile.AddDefinition(
   makefile.AddDefinition(
-    listName, cmList::prepend(args.begin() + 2, args.end(), listString));
+    listName, cmList::prepend(listString, args.begin() + 2, args.end()));
   return true;
   return true;
 }
 }
 
 

+ 1 - 3
Source/cmQtAutoGenInitializer.cxx

@@ -559,9 +559,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
           "Q_PLUGIN_METADATA",
           "Q_PLUGIN_METADATA",
           "[\n][ \t]*Q_PLUGIN_METADATA[ \t]*\\("
           "[\n][ \t]*Q_PLUGIN_METADATA[ \t]*\\("
           "[^\\)]*FILE[ \t]*\"([^\"]+)\"");
           "[^\\)]*FILE[ \t]*\"([^\"]+)\"");
-        for (cmList::index_type ii = 0;
-             ii != static_cast<cmList::index_type>(filterList.size());
-             ii += 2) {
+        for (cmList::size_type ii = 0; ii != filterList.size(); ii += 2) {
           this->Moc.DependFilters.emplace_back(filterList[ii],
           this->Moc.DependFilters.emplace_back(filterList[ii],
                                                filterList[ii + 1]);
                                                filterList[ii + 1]);
         }
         }

+ 3 - 3
Source/cmStringAlgorithms.h

@@ -97,14 +97,14 @@ inline void cmExpandList(cm::string_view arg,
                          std::vector<std::string>& argsOut,
                          std::vector<std::string>& argsOut,
                          bool emptyArgs = false)
                          bool emptyArgs = false)
 {
 {
-  cmList::append(arg, argsOut,
+  cmList::append(argsOut, arg,
                  emptyArgs ? cmList::EmptyElements::Yes
                  emptyArgs ? cmList::EmptyElements::Yes
                            : cmList::EmptyElements::No);
                            : cmList::EmptyElements::No);
 }
 }
 inline void cmExpandList(cmValue arg, std::vector<std::string>& argsOut,
 inline void cmExpandList(cmValue arg, std::vector<std::string>& argsOut,
                          bool emptyArgs = false)
                          bool emptyArgs = false)
 {
 {
-  cmList::append(arg, argsOut,
+  cmList::append(argsOut, arg,
                  emptyArgs ? cmList::EmptyElements::Yes
                  emptyArgs ? cmList::EmptyElements::Yes
                            : cmList::EmptyElements::No);
                            : cmList::EmptyElements::No);
 }
 }
@@ -118,7 +118,7 @@ template <class InputIt>
 void cmExpandLists(InputIt first, InputIt last,
 void cmExpandLists(InputIt first, InputIt last,
                    std::vector<std::string>& argsOut)
                    std::vector<std::string>& argsOut)
 {
 {
-  cmList::append(first, last, argsOut);
+  cmList::append(argsOut, first, last);
 }
 }
 
 
 /** Concatenate string pieces into a single string.  */
 /** Concatenate string pieces into a single string.  */

+ 35 - 34
Tests/CMakeLib/testList.cxx

@@ -9,6 +9,7 @@
 #include <vector>
 #include <vector>
 
 
 #include <cm/string_view>
 #include <cm/string_view>
+#include <cmext/string_view>
 
 
 #include "cmList.h"
 #include "cmList.h"
 
 
@@ -42,7 +43,7 @@ bool testConstructors()
   }
   }
   {
   {
     cmList list1{ "aa", "bb" };
     cmList list1{ "aa", "bb" };
-    cmList list2("aa;bb");
+    cmList list2("aa;bb"_s);
 
 
     if (list1.size() != 2 || list2.size() != 2 || list1 != list2) {
     if (list1.size() != 2 || list2.size() != 2 || list1 != list2) {
       result = false;
       result = false;
@@ -174,7 +175,7 @@ bool testAssign()
   {
   {
     cmList list{ "cc", "dd" };
     cmList list{ "cc", "dd" };
 
 
-    list = "aa;bb";
+    list = "aa;bb"_s;
     if (list.size() != 2) {
     if (list.size() != 2) {
       result = false;
       result = false;
     }
     }
@@ -195,7 +196,7 @@ bool testConversions()
   bool result = true;
   bool result = true;
 
 
   {
   {
-    cmList list("a;b;c");
+    cmList list("a;b;c"_s);
     std::string s = list.to_string();
     std::string s = list.to_string();
 
 
     if (s != "a;b;c") {
     if (s != "a;b;c") {
@@ -203,7 +204,7 @@ bool testConversions()
     }
     }
   }
   }
   {
   {
-    cmList list("a;b;c");
+    cmList list("a;b;c"_s);
     std::vector<std::string> v = list;
     std::vector<std::string> v = list;
 
 
     if (list.size() != 3 || v.size() != 3) {
     if (list.size() != 3 || v.size() != 3) {
@@ -211,7 +212,7 @@ bool testConversions()
     }
     }
   }
   }
   {
   {
-    cmList list("a;b;c");
+    cmList list("a;b;c"_s);
     std::vector<std::string> v = std::move(list);
     std::vector<std::string> v = std::move(list);
 
 
     // Microsoft compiler is not able to handle correctly the move semantics
     // Microsoft compiler is not able to handle correctly the move semantics
@@ -221,7 +222,7 @@ bool testConversions()
     }
     }
   }
   }
   {
   {
-    cmList list("a;b;c");
+    cmList list("a;b;c"_s);
     std::vector<std::string> v;
     std::vector<std::string> v;
 
 
     // compiler is not able to select the cmList conversion operator
     // compiler is not able to select the cmList conversion operator
@@ -247,20 +248,20 @@ bool testAccess()
 
 
   {
   {
     cmList list{ "a", "b", "c" };
     cmList list{ "a", "b", "c" };
-    if (list.at(1) != "b") {
+    if (list.get_item(1) != "b") {
       result = false;
       result = false;
     }
     }
   }
   }
   {
   {
     cmList list{ "a", "b", "c" };
     cmList list{ "a", "b", "c" };
-    if (list.at(-3) != "a") {
+    if (list.get_item(-3) != "a") {
       result = false;
       result = false;
     }
     }
   }
   }
   {
   {
     try {
     try {
       cmList list{ "a", "b", "c" };
       cmList list{ "a", "b", "c" };
-      if (list.at(4) != "a") {
+      if (list.get_item(4) != "a") {
         result = false;
         result = false;
       }
       }
     } catch (std::out_of_range&) {
     } catch (std::out_of_range&) {
@@ -269,7 +270,7 @@ bool testAccess()
   {
   {
     try {
     try {
       cmList list{ "a", "b", "c" };
       cmList list{ "a", "b", "c" };
-      if (list.at(-4) != "a") {
+      if (list.get_item(-4) != "a") {
         result = false;
         result = false;
       }
       }
     } catch (std::out_of_range&) {
     } catch (std::out_of_range&) {
@@ -342,7 +343,7 @@ bool testModifiers()
   {
   {
     cmList list{ "1;2;3;4;5" };
     cmList list{ "1;2;3;4;5" };
 
 
-    auto it = list.insert(list.begin() + 2, "6;7;8");
+    auto it = list.insert(list.begin() + 2, "6;7;8"_s);
     if (list.size() != 8 || list.to_string() != "1;2;6;7;8;3;4;5") {
     if (list.size() != 8 || list.to_string() != "1;2;6;7;8;3;4;5") {
       result = false;
       result = false;
     }
     }
@@ -354,7 +355,7 @@ bool testModifiers()
     cmList list{ "1;2;3;4;5" };
     cmList list{ "1;2;3;4;5" };
 
 
     auto it =
     auto it =
-      list.insert(list.begin() + 2, "6;7;8", cmList::ExpandElements::No);
+      list.insert(list.begin() + 2, "6;7;8"_s, cmList::ExpandElements::No);
     if (list.size() != 6 || list.to_string() != "1;2;6;7;8;3;4;5") {
     if (list.size() != 6 || list.to_string() != "1;2;6;7;8;3;4;5") {
       result = false;
       result = false;
     }
     }
@@ -479,7 +480,7 @@ bool testRemoveItems()
   bool result = true;
   bool result = true;
 
 
   {
   {
-    cmList list("a;b;c;d;e;f;g;h");
+    cmList list("a;b;c;d;e;f;g;h"_s);
 
 
     list.remove_items({ 1, 3, 5 });
     list.remove_items({ 1, 3, 5 });
 
 
@@ -488,7 +489,7 @@ bool testRemoveItems()
     }
     }
   }
   }
   {
   {
-    cmList list("a;b;c;b;a;d;e;f");
+    cmList list("a;b;c;b;a;d;e;f"_s);
 
 
     list.remove_items({ "a", "b", "h" });
     list.remove_items({ "a", "b", "h" });
 
 
@@ -497,7 +498,7 @@ bool testRemoveItems()
     }
     }
   }
   }
   {
   {
-    cmList list("a;b;c;d;e;f;g;h");
+    cmList list("a;b;c;d;e;f;g;h"_s);
     std::vector<cmList::index_type> remove{ 1, 3, 5 };
     std::vector<cmList::index_type> remove{ 1, 3, 5 };
 
 
     list.remove_items(remove.begin(), remove.end());
     list.remove_items(remove.begin(), remove.end());
@@ -507,7 +508,7 @@ bool testRemoveItems()
     }
     }
   }
   }
   {
   {
-    cmList list("a;b;c;b;a;d;e;f");
+    cmList list("a;b;c;b;a;d;e;f"_s);
     std::vector<std::string> remove{ "b", "a", "h" };
     std::vector<std::string> remove{ "b", "a", "h" };
 
 
     list.remove_items(remove.begin(), remove.end());
     list.remove_items(remove.begin(), remove.end());
@@ -529,7 +530,7 @@ bool testRemoveDuplicates()
   bool result = true;
   bool result = true;
 
 
   {
   {
-    cmList list("b;c;b;a;a;c;b;a;c;b");
+    cmList list("b;c;b;a;a;c;b;a;c;b"_s);
 
 
     list.remove_duplicates();
     list.remove_duplicates();
 
 
@@ -803,7 +804,7 @@ bool testStaticModifiers()
 
 
   {
   {
     std::vector<std::string> v{ "a", "b", "c" };
     std::vector<std::string> v{ "a", "b", "c" };
-    cmList::assign("d;e", v);
+    cmList::assign(v, "d;e"_s);
 
 
     if (v.size() != 2 || v[0] != "d" || v[1] != "e") {
     if (v.size() != 2 || v[0] != "d" || v[1] != "e") {
       result = false;
       result = false;
@@ -811,7 +812,7 @@ bool testStaticModifiers()
   }
   }
   {
   {
     std::vector<std::string> v{ "a", "b", "c" };
     std::vector<std::string> v{ "a", "b", "c" };
-    cmList::append("d;;e", v);
+    cmList::append(v, "d;;e"_s);
 
 
     if (v.size() != 5 || v[3] != "d" || v[4] != "e") {
     if (v.size() != 5 || v[3] != "d" || v[4] != "e") {
       result = false;
       result = false;
@@ -819,7 +820,7 @@ bool testStaticModifiers()
   }
   }
   {
   {
     std::vector<std::string> v{ "a", "b", "c" };
     std::vector<std::string> v{ "a", "b", "c" };
-    cmList::append("d;;e", v, cmList::EmptyElements::Yes);
+    cmList::append(v, "d;;e"_s, cmList::EmptyElements::Yes);
 
 
     if (v.size() != 6 || v[3] != "d" || !v[4].empty() || v[5] != "e") {
     if (v.size() != 6 || v[3] != "d" || !v[4].empty() || v[5] != "e") {
       result = false;
       result = false;
@@ -827,7 +828,7 @@ bool testStaticModifiers()
   }
   }
   {
   {
     std::vector<std::string> v{ "a", "b", "c" };
     std::vector<std::string> v{ "a", "b", "c" };
-    cmList::prepend("d;e", v);
+    cmList::prepend(v, "d;e"_s);
 
 
     if (v.size() != 5 || v[0] != "d" || v[1] != "e") {
     if (v.size() != 5 || v[0] != "d" || v[1] != "e") {
       result = false;
       result = false;
@@ -835,7 +836,7 @@ bool testStaticModifiers()
   }
   }
   {
   {
     std::vector<std::string> v{ "a", "b", "c" };
     std::vector<std::string> v{ "a", "b", "c" };
-    cmList::prepend("d;;e", v, cmList::EmptyElements::Yes);
+    cmList::prepend(v, "d;;e"_s, cmList::EmptyElements::Yes);
 
 
     if (v.size() != 6 || v[0] != "d" || !v[1].empty() || v[2] != "e") {
     if (v.size() != 6 || v[0] != "d" || !v[1].empty() || v[2] != "e") {
       result = false;
       result = false;
@@ -843,7 +844,7 @@ bool testStaticModifiers()
   }
   }
   {
   {
     std::string list{ "a;b;c" };
     std::string list{ "a;b;c" };
-    cmList::append("d;e", list);
+    cmList::append(list, "d;e"_s);
 
 
     if (list != "a;b;c;d;e") {
     if (list != "a;b;c;d;e") {
       result = false;
       result = false;
@@ -851,7 +852,7 @@ bool testStaticModifiers()
   }
   }
   {
   {
     std::string list;
     std::string list;
-    cmList::append("d;e", list);
+    cmList::append(list, "d;e"_s);
 
 
     if (list != "d;e") {
     if (list != "d;e") {
       result = false;
       result = false;
@@ -859,7 +860,7 @@ bool testStaticModifiers()
   }
   }
   {
   {
     std::string list{ "a;b;c" };
     std::string list{ "a;b;c" };
-    cmList::append("", list);
+    cmList::append(list, "");
 
 
     if (list != "a;b;c;") {
     if (list != "a;b;c;") {
       result = false;
       result = false;
@@ -868,7 +869,7 @@ bool testStaticModifiers()
   {
   {
     std::string list{ "a;b;c" };
     std::string list{ "a;b;c" };
     std::vector<std::string> v{ "d", "e" };
     std::vector<std::string> v{ "d", "e" };
-    cmList::append(v.begin(), v.end(), list);
+    cmList::append(list, v.begin(), v.end());
 
 
     if (list != "a;b;c;d;e") {
     if (list != "a;b;c;d;e") {
       result = false;
       result = false;
@@ -877,7 +878,7 @@ bool testStaticModifiers()
   {
   {
     std::string list{ "a;b;c" };
     std::string list{ "a;b;c" };
     std::vector<std::string> v;
     std::vector<std::string> v;
-    cmList::append(v.begin(), v.end(), list);
+    cmList::append(list, v.begin(), v.end());
 
 
     if (list != "a;b;c") {
     if (list != "a;b;c") {
       result = false;
       result = false;
@@ -886,7 +887,7 @@ bool testStaticModifiers()
   {
   {
     std::string list;
     std::string list;
     std::vector<std::string> v{ "d", "e" };
     std::vector<std::string> v{ "d", "e" };
-    cmList::append(v.begin(), v.end(), list);
+    cmList::append(list, v.begin(), v.end());
 
 
     if (list != "d;e") {
     if (list != "d;e") {
       result = false;
       result = false;
@@ -894,7 +895,7 @@ bool testStaticModifiers()
   }
   }
   {
   {
     std::string list{ "a;b;c" };
     std::string list{ "a;b;c" };
-    cmList::prepend("d;e", list);
+    cmList::prepend(list, "d;e");
 
 
     if (list != "d;e;a;b;c") {
     if (list != "d;e;a;b;c") {
       result = false;
       result = false;
@@ -902,7 +903,7 @@ bool testStaticModifiers()
   }
   }
   {
   {
     std::string list;
     std::string list;
-    cmList::prepend("d;e", list);
+    cmList::prepend(list, "d;e");
 
 
     if (list != "d;e") {
     if (list != "d;e") {
       result = false;
       result = false;
@@ -910,7 +911,7 @@ bool testStaticModifiers()
   }
   }
   {
   {
     std::string list{ "a;b;c" };
     std::string list{ "a;b;c" };
-    cmList::prepend("", list);
+    cmList::prepend(list, "");
 
 
     if (list != ";a;b;c") {
     if (list != ";a;b;c") {
       result = false;
       result = false;
@@ -919,7 +920,7 @@ bool testStaticModifiers()
   {
   {
     std::string list{ "a;b;c" };
     std::string list{ "a;b;c" };
     std::vector<std::string> v{ "d", "e" };
     std::vector<std::string> v{ "d", "e" };
-    cmList::prepend(v.begin(), v.end(), list);
+    cmList::prepend(list, v.begin(), v.end());
 
 
     if (list != "d;e;a;b;c") {
     if (list != "d;e;a;b;c") {
       result = false;
       result = false;
@@ -928,7 +929,7 @@ bool testStaticModifiers()
   {
   {
     std::string list{ "a;b;c" };
     std::string list{ "a;b;c" };
     std::vector<std::string> v;
     std::vector<std::string> v;
-    cmList::prepend(v.begin(), v.end(), list);
+    cmList::prepend(list, v.begin(), v.end());
 
 
     if (list != "a;b;c") {
     if (list != "a;b;c") {
       result = false;
       result = false;
@@ -937,7 +938,7 @@ bool testStaticModifiers()
   {
   {
     std::string list;
     std::string list;
     std::vector<std::string> v{ "d", "e" };
     std::vector<std::string> v{ "d", "e" };
-    cmList::prepend(v.begin(), v.end(), list);
+    cmList::prepend(list, v.begin(), v.end());
 
 
     if (list != "d;e") {
     if (list != "d;e") {
       result = false;
       result = false;