From 3a1a35348399f8cf2f618a3dbee114f6cd10c8c7 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Wed, 24 Apr 2019 18:26:57 +0200
Subject: [PATCH] STYLE: remove UList operator[] taking std::initializer_list

- unnecessary. Can deduce labelRange from the pair of labels.
  These are all the same:

      list[labelRange(18,3)] = 100;
      list[labelRange{18,3}] = 100;
      list[{18,3}] = 100;

  Removing the run-time handling of std::initializer_list in favour of
  compile-time deduction allows the future use of sliceRange as well.
  Eg,

     list[sliceRange{18,3,2}] = 100;
     list[{18,3,2}] = 100;
---
 src/OpenFOAM/containers/Lists/UList/UList.C | 50 +--------------------
 src/OpenFOAM/containers/Lists/UList/UList.H | 19 --------
 2 files changed, 1 insertion(+), 68 deletions(-)

diff --git a/src/OpenFOAM/containers/Lists/UList/UList.C b/src/OpenFOAM/containers/Lists/UList/UList.C
index 413cec76e00..ece482a0398 100644
--- a/src/OpenFOAM/containers/Lists/UList/UList.C
+++ b/src/OpenFOAM/containers/Lists/UList/UList.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2017-2019 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
                             | Copyright (C) 2011-2016 OpenFOAM Foundation
@@ -48,29 +48,6 @@ Foam::labelRange Foam::UList<T>::validateRange(const labelRange& range) const
 }
 
 
-template<class T>
-Foam::labelRange Foam::UList<T>::validateRange
-(
-    std::initializer_list<label> start_size
-) const
-{
-    if (start_size.size() != 2)
-    {
-        FatalErrorInFunction
-            << "range specified with " << start_size.size()
-            << " elements instead of 2"
-            << abort(FatalError);
-    }
-
-    auto iter = start_size.begin();
-
-    const label beg = *(iter++);
-    const label len = *iter;
-
-    return this->validateRange(labelRange(beg, len));
-}
-
-
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class T>
@@ -176,31 +153,6 @@ const Foam::UList<T> Foam::UList<T>::operator[](const labelRange& range) const
 }
 
 
-template<class T>
-Foam::UList<T> Foam::UList<T>::operator[]
-(
-    std::initializer_list<label> start_size
-)
-{
-    const labelRange slice = validateRange(start_size);
-
-    return UList<T>(&(this->v_[slice.start()]), slice.size()); // SubList
-}
-
-
-template<class T>
-const Foam::UList<T> Foam::UList<T>::operator[]
-(
-    std::initializer_list<label> start_size
-) const
-{
-    // Restricted range
-    const labelRange slice = validateRange(start_size);
-
-    return UList<T>(&(this->v_[slice.start()]), slice.size()); // SubList
-}
-
-
 template<class T>
 void Foam::UList<T>::operator=(const T& val)
 {
diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H
index 0aa8492bd28..7ea917510bf 100644
--- a/src/OpenFOAM/containers/Lists/UList/UList.H
+++ b/src/OpenFOAM/containers/Lists/UList/UList.H
@@ -123,12 +123,6 @@ protected:
         //- always addresses a valid section of the list.
         labelRange validateRange(const labelRange& range) const;
 
-        //- Return a validated (start,size) subset range, which means that it
-        //- always addresses a valid section of the list.
-        labelRange validateRange
-        (
-            std::initializer_list<label> start_size_pair
-        ) const;
 
 public:
 
@@ -361,19 +355,6 @@ public:
         //  result always addresses a valid section of the list.
         const UList<T> operator[](const labelRange& range) const;
 
-        //- Return (start,size) subset from UList with non-const access.
-        //  The range is subsetted with the list size itself to ensure that the
-        //  result always addresses a valid section of the list.
-        UList<T> operator[](std::initializer_list<label> start_size);
-
-        //- Return (start,size) subset from UList with const access.
-        //  The range is subsetted with the list size itself to ensure that the
-        //  result always addresses a valid section of the list.
-        const UList<T> operator[]
-        (
-            std::initializer_list<label> start_size
-        ) const;
-
         //- Allow cast to a const List<T>&
         inline operator const Foam::List<T>&() const;
 
-- 
GitLab