From 34aecd4f40f22e73e4b401e8a8f18bf99c0cd5b3 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Thu, 28 May 2015 20:47:02 +0000 Subject: [PATCH] Revert "Refactoring cl::list_storage from "is a" to "has a" std::vector." This reverts commit 117715ca0613d3db144241499401f2ec5398f1d5. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238491 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/CommandLine.h | 59 ++++-------------------------- 1 file changed, 7 insertions(+), 52 deletions(-) diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 24630dbbdc1..bd1d1cb6dc9 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -1284,61 +1284,16 @@ public: } }; -// Define how to hold a class type object, such as a string. -// Originally this code inherited from std::vector. In transitioning to a new -// API for command line options we should change this. The new implementation -// of this list_storage specialization implements the minimum subset of the -// std::vector API required for all the current clients. -// -// FIXME: Reduce this API to a more narrow subset of std::vector +// Define how to hold a class type object, such as a string. Since we can +// inherit from a class, we do so. This makes us exactly compatible with the +// object in all cases that it is used. // -template class list_storage { - std::vector Storage; - +template +class list_storage : public std::vector { public: - typedef typename std::vector::iterator iterator; - - iterator begin() { return Storage.begin(); } - iterator end() { return Storage.end(); } - - typedef typename std::vector::const_iterator const_iterator; - const_iterator begin() const { return Storage.begin(); } - const_iterator end() const { return Storage.end(); } - - typedef typename std::vector::size_type size_type; - size_type size() const { return Storage.size(); } - - bool empty() const { return Storage.empty(); } - - void push_back(const DataType &value) { Storage.push_back(value); } - void push_back(DataType &&value) { Storage.push_back(value); } - - typedef typename std::vector::reference reference; - typedef typename std::vector::const_reference const_reference; - reference operator[](size_type pos) { return Storage[pos]; } - const_reference operator[](size_type pos) const { return Storage[pos]; } - - iterator erase(const_iterator pos) { return Storage.erase(pos); } - iterator erase(const_iterator first, const_iterator last) { - return Storage.erase(first, last); - } - - iterator insert(const_iterator pos, const DataType &value) { - return Storage.insert(pos, value); - } - iterator insert(const_iterator pos, DataType &&value) { - return Storage.insert(pos, value); + template void addValue(const T &V) { + std::vector::push_back(V); } - - reference front() { return Storage.front(); } - const_reference front() const { return Storage.front(); } - - operator std::vector&() { return Storage; } - operator ArrayRef() { return Storage; } - std::vector *operator&() { return &Storage; } - const std::vector *operator&() const { return &Storage; } - - template void addValue(const T &V) { Storage.push_back(V); } }; //===----------------------------------------------------------------------===// -- 2.34.1