Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r48886 - sandbox/committee/concepts/stdlib
From: dgregor_at_[hidden]
Date: 2008-09-19 05:47:21


Author: dgregor
Date: 2008-09-19 05:47:20 EDT (Fri, 19 Sep 2008)
New Revision: 48886
URL: http://svn.boost.org/trac/boost/changeset/48886

Log:
Demote back()
Text files modified:
   sandbox/committee/concepts/stdlib/clib-containers.tex | 69 ++++++++++++++++++++-------------------
   1 files changed, 35 insertions(+), 34 deletions(-)

Modified: sandbox/committee/concepts/stdlib/clib-containers.tex
==============================================================================
--- sandbox/committee/concepts/stdlib/clib-containers.tex (original)
+++ sandbox/committee/concepts/stdlib/clib-containers.tex 2008-09-19 05:47:20 EDT (Fri, 19 Sep 2008)
@@ -119,6 +119,7 @@
   the requirements of the \tcode{ForwardIterator} concept, rather than
   the \tcode{InputIterator} concept.
 \item Renamed uses of \tcode{ConstructibleAsElement} to \tcode{AllocatableElement}.
+\item Moved the \tcode{back()} requirement from \tcode{BackInsertionContainer} to \tcode{StackLikeContainer}.
 \end{itemize}
 
 \end{titlepage}
@@ -1012,18 +1013,7 @@
 
 \begin{itemdecl}
 concept BackInsertionContainer<typename C> : Container<C> {
- reference back(C&);
- const_reference back(const C&);
-
   void push_back(C&, value_type&&);
-
- requires BidirectionalIterator<iterator> axiom AccessBack(C c) {
- if (begin(c) != end(c)) back(c) == *(--end(c));
- }
-
- axiom BackInsertion(C c, value_type x) {
- x == (push_back(c, x), back(c));
- }
 }
 \end{itemdecl}
 
@@ -1038,8 +1028,19 @@
 
 \begin{itemdecl}
 concept StackLikeContainer<typename C> : BackInsertionContainer<C> {
+ reference back(C&);
+ const_reference back(const C&);
+
   void pop_back(C&);
 
+ requires BidirectionalIterator<iterator> axiom AccessBack(C c) {
+ if (begin(c) != end(c)) back(c) == *(--end(c));
+ }
+
+ axiom BackInsertion(C c, value_type x) {
+ x == (push_back(c, x), back(c));
+ }
+
   axiom BackRemoval(C c, value_type x) {
     c == (push_back(c, x), pop_back(c), c);
   }
@@ -1124,12 +1125,12 @@
 concept BackEmplacementContainer<typename C, typename... Args> : Container<C> {
   void emplace_back(C& c, Args&&... args);
 
- requires Constructible<value_type, Args...>
+ requires StackLikeContainer<C> && Constructible<value_type, Args...>
     axiom BackEmplacement(C c, Args... args) {
       value_type(args...) == (emplace_back(c, args...), back(c));
     }
 
- requires BackInsertionContainer<C> && Constructible<value_type, Args...>
+ requires StackLikeContainer<C> && Constructible<value_type, Args...>
     axiom BackEmplacementPushEquivalence(C c, Args... args) {
       (emplace_back(c, args...), back(c)) == (push_back(c, value_type(args...)), back(c));
     }
@@ -1253,18 +1254,7 @@
 
 \begin{itemdecl}
 auto concept MemberBackInsertionContainer<typename C> : MemberContainer<C> {
- reference C::back();
- const_reference C::back() const;
-
   void C::push_back(value_type&&);
-
- requires BidirectionalIterator<iterator> axiom MemberAccessBack(C c) {
- if (c.begin() != c.end()) c.back() == *(--c.end());
- }
-
- axiom MemberBackInsertion(C c, value_type x) {
- x == (c.push_back(x), c.back());
- }
 }
 \end{itemdecl}
 
@@ -1278,8 +1268,19 @@
 
 \begin{itemdecl}
 auto concept MemberStackLikeContainer<typename C> : MemberBackInsertionContainer<C> {
+ reference C::back();
+ const_reference C::back() const;
+
   void C::pop_back();
 
+ requires BidirectionalIterator<iterator> axiom MemberAccessBack(C c) {
+ if (c.begin() != c.end()) c.back() == *(--c.end());
+ }
+
+ axiom MemberBackInsertion(C c, value_type x) {
+ x == (c.push_back(x), c.back());
+ }
+
   axiom MemberBackRemoval(C c, value_type x) {
     c == (c.push_back(x), c.pop_back(), c);
   }
@@ -1344,7 +1345,7 @@
 
   requires Constructible<value_type, Args...>
     axiom MemberFrontEmplacement(C c, Args... args) {
- value_type(args...) == (c.emplace_front(args...), front(c));
+ value_type(args...) == (c.emplace_front(args...), c.front());
     }
 
   requires MemberFrontInsertionContainer<C> && Constructible<value_type, Args...>
@@ -1364,12 +1365,12 @@
 auto concept MemberBackEmplacementContainer<typename C, typename... Args> : MemberBackInsertionContainer<C> {
   void C::emplace_back(Args&&... args);
 
- requires Constructible<value_type, Args...>
+ requires MemberStackLikeContainer<C> && Constructible<value_type, Args...>
     axiom MemberBackEmplacement(C c, Args... args) {
- value_type(args...) == (c.emplace_back(args...), back(c));
+ value_type(args...) == (c.emplace_back(args...), c.back());
     }
 
- requires BackInsertionContainer<C> && Constructible<value_type, Args...>
+ requires MemberStackLikeContainer<C> && Constructible<value_type, Args...>
     axiom MemberBackEmplacementPushEquivalence(C c, Args... args) {
       (c.emplace_back(args...), c.back()) == (c.push_back(value_type(args...)), c.back());
     }
@@ -1469,11 +1470,6 @@
 template <MemberBackInsertionContainer C>
 concept_map BackInsertionContainer<C> {
   typedef Container<C>::value_type value_type;
- typedef Container<C>::reference reference;
- typedef Container<C>::const_reference const_reference;
-
- reference back(C& c) { return c.back(); }
- const_reference back(const C& c) { return c.back(); }
 
   void push_back(C& c, value_type&& v) { c.push_back(static_cast<value_type&&>(v)); }
 }
@@ -1489,7 +1485,12 @@
 \begin{itemdecl}
 template <MemberStackLikeContainer C>
 concept_map StackLikeContainer<C> {
- void pop_back(C& c) { c.pop_back(); }
+ typedef Container<C>::reference reference;
+ typedef Container<C>::const_reference const_reference;
+
+ reference back(C& c) { return c.back(); }
+ const_reference back(const C& c) { return c.back(); }
+ void pop_back(C& c) { c.pop_back(); }
 }
 \end{itemdecl}
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk