From 8a00e706f2d7848cb6e905d1b6f2cd00699ecbef Mon Sep 17 00:00:00 2001 From: nobody Date: Thu, 5 Jun 2003 05:15:05 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'mpl_v2_2'. [SVN r18675] --- array.hpp.html | 175 ---------------- array.html | 330 ----------------------------- array1.cpp | 59 ------ array1.cpp.html | 69 ------ array2.cpp | 41 ---- array2.cpp.html | 56 ----- array3.cpp | 56 ----- array3.cpp.html | 71 ------- array4.cpp | 44 ---- array4.cpp.html | 59 ------ array5.cpp | 73 ------- array5.cpp.html | 87 -------- doc/array.xml | 545 ------------------------------------------------ index.htm | 35 ---- print.hpp | 28 --- print.hpp.html | 48 ----- 16 files changed, 1776 deletions(-) delete mode 100644 array.hpp.html delete mode 100644 array.html delete mode 100644 array1.cpp delete mode 100644 array1.cpp.html delete mode 100644 array2.cpp delete mode 100644 array2.cpp.html delete mode 100644 array3.cpp delete mode 100644 array3.cpp.html delete mode 100644 array4.cpp delete mode 100644 array4.cpp.html delete mode 100644 array5.cpp delete mode 100644 array5.cpp.html delete mode 100644 doc/array.xml delete mode 100644 index.htm delete mode 100644 print.hpp delete mode 100644 print.hpp.html diff --git a/array.hpp.html b/array.hpp.html deleted file mode 100644 index 964837b..0000000 --- a/array.hpp.html +++ /dev/null @@ -1,175 +0,0 @@ - - -array.hpp - - - -  - -
- - array.hpp - -

- -

- - -/* The following code declares class array,
* an STL container (as wrapper) for arrays of constant size.
*
* See
*      http://www.josuttis.com/cppcode
* for details and the latest version.
*
* (C) Copyright Nicolai M. Josuttis 2001.
* Permission to copy, use, modify, sell and distribute this software
* is granted provided this copyright notice appears in all copies.
* This software is provided "as is" without express or implied
* warranty, and with no claim as to its suitability for any purpose.
*
* Aug 05, 2001
*/
-#ifndef BOOST_ARRAY_HPP
-#define BOOST_ARRAY_HPP
-
-#include <cstddef>
-#include <stdexcept>
-#include <iterator>
-#include <algorithm>
-
-// FIXES for broken compilers
-#include <boost/config.hpp>
-
-namespace boost {
-
-    template<class T, std::size_t N>
-    class array {
-      public:
-        T elems[N];    // fixed-size array of elements of type T
-
-      public:
-        // type definitions
-        typedef T              value_type;
-        typedef T*             iterator;
-        typedef const T*       const_iterator;
-        typedef T&             reference;
-        typedef const T&       const_reference;
-        typedef std::size_t    size_type;
-        typedef std::ptrdiff_t difference_type;
-    
-        // iterator support
-        iterator begin() { return elems; }
-        const_iterator begin() const { return elems; }
-        iterator end() { return elems+N; }
-        const_iterator end() const { return elems+N; }
-
-        // reverse iterator support
-#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR)
-        typedef std::reverse_iterator<iterator> reverse_iterator;
-        typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
-#else
-        // workaround for broken reverse_iterator implementations
-        typedef std::reverse_iterator<iterator,T> reverse_iterator;
-        typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator;
-#endif
-
-        reverse_iterator rbegin() { return reverse_iterator(end()); }
-        const_reverse_iterator rbegin() const {
-            return const_reverse_iterator(end());
-        }
-        reverse_iterator rend() { return reverse_iterator(begin()); }
-        const_reverse_iterator rend() const {
-            return const_reverse_iterator(begin());
-        }
-
-        // operator[]
-        reference operator[](size_type i) { return elems[i]; }
-        const_reference operator[](size_type i) const { return elems[i]; }
-
-        // at() with range check
-        reference at(size_type i) { rangecheck(i); return elems[i]; }
-        const_reference at(size_type i) const { rangecheck(i); return elems[i]; }
-    
-        // front() and back()
-        reference front() { return elems[0]; }
-        const_reference front() const { return elems[0]; }
-        reference back() { return elems[N-1]; }
-        const_reference back() const { return elems[N-1]; }
-
-        // size is constant
-        static size_type size() { return N; }
-        static bool empty() { return false; }
-        static size_type max_size() { return N; }
-        enum { static_size = N };
-
-        // swap (note: linear complexity)
-        void swap (array<T,N>& y) {
-            std::swap_ranges(begin(),end(),y.begin());
-        }
-
-        // direct access to data
-        const T* data() const { return elems; }
-
-        // assignment with type conversion
-        template <typename T2>
-        array<T,N>& operator= (const array<T2,N>& rhs) {
-            std::copy(rhs.begin(),rhs.end(), begin());
-            return *this;
-        }
-
-        // assign one value to all elements
-        void assign (const T& value)
-        {
-            std::fill_n(begin(),size(),value);
-        }
-
-#ifndef BOOST_NO_PRIVATE_IN_AGGREGATE
-      private:
-#endif
-        // check range (may be private because it is static)
-        static void rangecheck (size_type i) {
-            if (i >= size()) { throw std::range_error("array"); }
-        }
-
-    };
-
-    // comparisons
-    template<class T, std::size_t N>
-    bool operator== (const array<T,N>& x, const array<T,N>& y) {
-        return std::equal(x.begin(), x.end(), y.begin());
-    }
-    template<class T, std::size_t N>
-    bool operator< (const array<T,N>& x, const array<T,N>& y) {
-        return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());
-    }
-    template<class T, std::size_t N>
-    bool operator!= (const array<T,N>& x, const array<T,N>& y) {
-        return !(x==y);
-    }
-    template<class T, std::size_t N>
-    bool operator> (const array<T,N>& x, const array<T,N>& y) {
-        return y<x;
-    }
-    template<class T, std::size_t N>
-    bool operator<= (const array<T,N>& x, const array<T,N>& y) {
-        return !(y<x);
-    }
-    template<class T, std::size_t N>
-    bool operator>= (const array<T,N>& x, const array<T,N>& y) {
-        return !(x<y);
-    }
-
-    // global swap()
-    template<class T, std::size_t N>
-    inline void swap (array<T,N>& x, array<T,N>& y) {
-        x.swap(y);
-    }
-
-} /* namespace boost */
-
-#endif /*BOOST_ARRAY_HPP*/
-
-
- - diff --git a/array.html b/array.html deleted file mode 100644 index 2d913e3..0000000 --- a/array.html +++ /dev/null @@ -1,330 +0,0 @@ - - - - - - -array.hpp, an STL Array Wrapper - - -  - - - - -
Class - array, an STL Container (as - Wrapper) for Arrays of Constant Size
-

[intro] - [interface] [discussion] - [code] -

The - C++ Standard Template Library STL as part of the C++ Standard Library provides - a framework for processing algorithms on different kind of containers. However, - ordinary arrays don't provide the interface of STL containers (although, they - provide the iterator interface of STL containers). -

As replacement for ordinary - arrays, the STL provides class vector<>. - However, vector<> provides - the semantics of dynamic arrays. Thus, it manages data to be able to change - the number of elements. This results in some overhead in case only arrays with - static size are needed. -

In his book, Generic - Programming and the STL, Matthew H. Austern introduces a useful wrapper - class for ordinary arrays with static size, called block. - It is safer and has no worse performance than ordinary arrays. In The C++ - Programming Language, 3rd edition, Bjarne Stroustrup introduces a similar - class, called c_array, - which I (Nicolai Josuttis) present slightly - modified in my book The C++ Standard Library - A Tutorial and Reference, - called carray. This is - the essence of these approaches spiced with many feedback from boost. -

After considering different - names, we decided to name this class simply array. -

The - class provides the following interface: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Types:
value_typetype of the elements
iteratortype of the iterator - (random-access iterator)
const_iteratortype of iterator that - considers elements as being constant
referencetype of element reference
const_referencetype of element reference - that considers elements as being constant
size_typetype for signed size - values
difference_typetype for unsigned - difference values
Operations:
-

array<type,num>

-
default constructor, - creates array of num - element of type, see - comment below
array<type,num>(a)copy constructor, - copies all elements of a - (a must have same - type - and num)
operator=assignment, assigns - all elements
assign(val)assigns val - to all elements
begin()returns iterator for - the first element
end()returns iterator for - position after the last element
rbegin()returns reverse iterator - for position of first element of reverse iteration
rend()returns reverse iterator - for position behind last element of reverse iteration
operator[i]returns element with - index i (no range - checking)
at(i)returns element with - index i (throw std::range_error - if i is not valid)
front()returns first element - (caller has to ensure that it exists)
back()returns last element - (caller has to ensure that it exists)
data()returns raw element - array for read-only element access
size()returns number of - elements
empty()returns whether array - is empty
max_size()returns maximum possible - number of elements (same as size())
swap(a)swap elements with - array a
==, - !=checks for equality
<, - <=, >, - >=compares array
Values: 
static_sizeyields size at compile - time
-

Class - array fulfills most but not all of the requirements of "reversible containers" - (see Section 23.1, [lib.container.requirements] of the C++ Standard). The reasons - array is not an reversible STL container is because:
- - No constructors are provided
- - Elements may have an undetermined initial value (see below)
- - swap() has no constant complexity
- - size() is always constant, based on the second template argument of the type
- - The container provides no allocator support
-

It doesn't fulfill the - requirements of a "sequence" (see Section 23.1.1, [lib.sequence.reqmts] - of the C++ Standard), except that
- - front() and back() are provided
- - operator[] and at() are provided
-

Regarding the constructors - there was an important design tradeoff: We could implement array as an "aggregate" - (see Section 8.5.1, [dcl.init.aggr], of the C++ Standard). This would mean:

- -

The current implementation - uses this approach. However, being able to have indeterminate initial values - is a big drawback. So, please give me some feedback, how useful you consider - this feature to be. This leads to the list of Open issues: -

-

I'd appreciate any constructive - feedback. Please note: I don't - have time to read all boost mails. Thus, to make sure that feedback arrives - me, please send me a copy of each mail regarding this class. -

The code is provided - "as is" without expressed or implied warranty. -

array.hpp, the implementation - of array<>: -

  • - as HTML file
  • -
  • - as plain file
  • -

    array1.cpp, a simple example - for using array<>: -

  • - as HTML file
  • -
  • - as plain file
  • -

    array2.cpp, another example - for using array<>: -

  • - as HTML file
  • -
  • - as plain file
  • -

    array3.cpp, a third example - for using array<>: -

  • - as HTML file
  • -
  • - as plain file
  • -

    array4.cpp, an example for - using arrays of arrays: -

  • as HTML - file
  • -
  • as plain file
  • -

    array5.cpp, an example for - testing other operations of array<>: -

  • as HTML - file
  • -
  • as plain file
  • -
    -
    - - To find more details about using ordinary arrays in C++ and the framework of - the STL, see e.g.
    -      The C++ - Standard Library - A Tutorial and Reference
    -      by Nicolai - M. Josuttis

    -      Addison Wesley Longman, 1999

    -      ISBN 0-201-37926-0

    -
    -

    Home - Page of Nicolai Josuttis - -

    [intro] - [interface] [discussion] - [code] -

    -

      - - diff --git a/array1.cpp b/array1.cpp deleted file mode 100644 index b5f45c1..0000000 --- a/array1.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* simple example for using class array<> - * - * (C) Copyright Nicolai M. Josuttis 2001. - * Permission to copy, use, modify, sell and distribute this software - * is granted provided this copyright notice appears in all copies. - * This software is provided "as is" without express or implied - * warranty, and with no claim as to its suitability for any purpose. - * - * Changelog: - * 20 Jan 2001 - Removed boolalpha use since stock GCC doesn't support it - * (David Abrahams) - */ - -#include -#include - -int main() -{ - // define special type name - typedef boost::array Array; - - // create and initialize an array - Array a = { { 42 } }; - - // access elements - for (unsigned i=1; i - -array1.cpp - - - -  - -
    - - array1.cpp - -

    - -

    - - -/* simple example for using class array<>
    */
    -#include <iostream>
    -#include <boost/array.hpp>
    -
    -int main()
    -{
    -    // define special type name
    -    typedef boost::array<float,6> Array;
    -
    -    // create and initialize an array
    -    Array a = { { 42 } };
    -
    -    // access elements
    -    for (unsigned i=1; i<a.size(); ++i) {
    -        a[i] = a[i-1]+1;
    -    }
    -
    -    // use some common STL container operations
    -    std::cout << "size:     " << a.size() << std::endl;
    -    std::cout << "empty:    " << std::boolalpha << a.empty() << std::endl;
    -    std::cout << "max_size: " << a.max_size() << std::endl;
    -    std::cout << "front:    " << a.front() << std::endl;
    -    std::cout << "back:     " << a.back() << std::endl;
    -    std::cout << "elems:    ";
    -
    -    // iterate through all elements
    -    for (Array::const_iterator pos=a.begin(); pos<a.end(); ++pos) {
    -        std::cout << *pos << ' ';
    -    }
    -    std::cout << std::endl;
    -
    -    // check copy constructor and assignment operator
    -    Array b(a);
    -    Array c;
    -    c = a;
    -    if (a==b && a==c) {
    -        std::cout << "copy construction and copy assignment are OK"
    -                  << std::endl;
    -    }
    -    else {
    -        std::cout << "copy construction and copy assignment FAILED"
    -                  << std::endl;
    -    }
    -
    -    return 0;  // makes Visual-C++ compiler happy
    -}
    -
    -
    -
    - - diff --git a/array2.cpp b/array2.cpp deleted file mode 100644 index f75cc3d..0000000 --- a/array2.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* example for using class array<> - * (C) Copyright Nicolai M. Josuttis 2001. - * Permission to copy, use, modify, sell and distribute this software - * is granted provided this copyright notice appears in all copies. - * This software is provided "as is" without express or implied - * warranty, and with no claim as to its suitability for any purpose. - */ - -#include -#include -#include -#include "print.hpp" -using namespace std; -using namespace boost; - -int main() -{ - // create and initialize array - array a = { { 1, 2, 3, 4, 5 } }; - - print_elements(a); - - // modify elements directly - for (unsigned i=0; i()); // operation - print_elements(a); - - return 0; // makes Visual-C++ compiler happy -} - diff --git a/array2.cpp.html b/array2.cpp.html deleted file mode 100644 index d2391c0..0000000 --- a/array2.cpp.html +++ /dev/null @@ -1,56 +0,0 @@ - - -array2.cpp - - - -  - -
    - - array2.cpp - -

    - -

    - - -/* example for using class array<>
    */
    -#include <algorithm>
    -#include <functional>
    -#include <boost/array.hpp>
    -#include "print.hpp"
    -using namespace std;
    -using namespace boost;
    -
    -int main()
    -{
    -    // create and initialize array
    -    array<int,10> a = { { 1, 2, 3, 4, 5 } };
    -
    -    print_elements(a);
    -
    -    // modify elements directly
    -    for (unsigned i=0; i<a.size(); ++i) {
    -        ++a[i];
    -    }
    -    print_elements(a);
    -
    -    // change order using an STL algorithm
    -    reverse(a.begin(),a.end());
    -    print_elements(a);
    -
    -    // negate elements using STL framework
    -    transform(a.begin(),a.end(),    // source
    -              a.begin(),            // destination
    -              negate<int>());       // operation
    -    print_elements(a);
    -
    -    return 0;  // makes Visual-C++ compiler happy
    -}
    -
    -
    -
    - - diff --git a/array3.cpp b/array3.cpp deleted file mode 100644 index 69ff81d..0000000 --- a/array3.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* example for using class array<> - * (C) Copyright Nicolai M. Josuttis 2001. - * Permission to copy, use, modify, sell and distribute this software - * is granted provided this copyright notice appears in all copies. - * This software is provided "as is" without express or implied - * warranty, and with no claim as to its suitability for any purpose. - */ - -#include -#include -#include - -template -void print_elements (const T& x); - -int main() -{ - // create array of four seasons - boost::array seasons = { - { "spring", "summer", "autumn", "winter" } - }; - - // copy and change order - boost::array seasons_orig = seasons; - for (unsigned i=seasons.size()-1; i>0; --i) { - std::swap(seasons.at(i),seasons.at((i+1)%seasons.size())); - } - - std::cout << "one way: "; - print_elements(seasons); - - // try swap() - std::cout << "other way: "; - std::swap(seasons,seasons_orig); - print_elements(seasons); - - // try reverse iterators - std::cout << "reverse: "; - for (boost::array::reverse_iterator pos - =seasons.rbegin(); pos -void print_elements (const T& x) -{ - for (unsigned i=0; i - -array3.cpp - - - -  - -
    - - array3.cpp - -

    - -

    - - -/* example for using class array<>
    */
    -#include <string>
    -#include <iostream>
    -#include <boost/array.hpp>
    -
    -template <class T>
    -void print_elements (const T& x);
    -
    -int main()
    -{
    -    // create array of four seasons
    -    boost::array<std::string,4> seasons = {
    -        { "spring", "summer", "autumn", "winter" }
    -    };
    -
    -    // copy and change order
    -    boost::array<std::string,4> seasons_orig = seasons;
    -    for (unsigned i=seasons.size()-1; i>0; --i) {
    -        swap(seasons.at(i),seasons.at((i+1)%seasons.size()));
    -    }
    -
    -    std::cout << "one way:   ";
    -    print_elements(seasons);
    -
    -    // try swap()
    -    std::cout << "other way: ";
    -    swap(seasons,seasons_orig);
    -    print_elements(seasons);
    -
    -    // try reverse iterators
    -    std::cout << "reverse:   ";
    -    for (boost::array<std::string,4>::reverse_iterator pos
    -           =seasons.rbegin(); pos<seasons.rend(); ++pos) {
    -        std::cout << " " << *pos;
    -    }
    -    std::cout << std::endl;
    -
    -    return 0;  // makes Visual-C++ compiler happy
    -}
    -
    -template <class T>
    -void print_elements (const T& x)
    -{
    -    for (unsigned i=0; i<x.size(); ++i) {
    -        std::cout << " " << x[i];
    -    }
    -    std::cout << std::endl;
    -}
    -
    -
    -
    - - diff --git a/array4.cpp b/array4.cpp deleted file mode 100644 index a0a1196..0000000 --- a/array4.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* example for using class array<> - * (C) Copyright Nicolai M. Josuttis 2001. - * Permission to copy, use, modify, sell and distribute this software - * is granted provided this copyright notice appears in all copies. - * This software is provided "as is" without express or implied - * warranty, and with no claim as to its suitability for any purpose. - */ - -#include -#include -#include -#include -#include - -int main() -{ - // array of arrays of seasons - boost::array,2> seasons_i18n = { - { { { "spring", "summer", "autumn", "winter", } }, - { { "Fruehling", "Sommer", "Herbst", "Winter" } } - } - }; - - // for any array of seasons print seasons - for (unsigned i=0; i seasons = seasons_i18n[i]; - for (unsigned j=0; j - -array4.cpp - - - -  - -
    - - array4.cpp - -

    - -

    - - -/* example for using class array<>
    */
    -#include <algorithm>
    -#include <functional>
    -#include <string>
    -#include <iostream>
    -#include <boost/array.hpp>
    -
    -int main()
    -{
    -    // array of arrays of seasons
    -    boost::array<boost::array<std::string,4>,2> seasons_i18n = {
    -        { { { "spring", "summer", "autumn", "winter", } },
    -          { { "Fruehling", "Sommer", "Herbst", "Winter" } }
    -        }
    -    };
    -
    -    // for any array of seasons print seasons
    -    for (unsigned i=0; i<seasons_i18n.size(); ++i) {
    -        boost::array<std::string,4> seasons = seasons_i18n[i];
    -        for (unsigned j=0; j<seasons.size(); ++j) {
    -            std::cout << seasons[j] << " ";
    -        }
    -        std::cout << std::endl;
    -    }
    -
    -    // print first element of first array
    -    std::cout << "first element of first array: "
    -              << seasons_i18n[0][0] << std::endl;
    -
    -    // print last element of last array
    -    std::cout << "last element of last array: "
    -              << seasons_i18n[seasons_i18n.size()-1][seasons_i18n[0].size()-1]
    -              << std::endl;
    -
    -    return 0;  // makes Visual-C++ compiler happy
    -}
    -
    -
    -
    - - diff --git a/array5.cpp b/array5.cpp deleted file mode 100644 index ad74525..0000000 --- a/array5.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* simple example for using class array<> - * (C) Copyright Nicolai M. Josuttis 2001. - * Permission to copy, use, modify, sell and distribute this software - * is granted provided this copyright notice appears in all copies. - * This software is provided "as is" without express or implied - * warranty, and with no claim as to its suitability for any purpose. - */ - -#include -#include - -template -void test_static_size (const T& cont) -{ - int tmp[T::static_size]; - for (unsigned i=0; i Array; - - // create and initialize an array - const Array a = { { 42.42 } }; - - // use some common STL container operations - std::cout << "static_size: " << a.size() << std::endl; - std::cout << "size: " << a.size() << std::endl; - // Can't use std::boolalpha because it isn't portable - std::cout << "empty: " << (a.empty()? "true" : "false") << std::endl; - std::cout << "max_size: " << a.max_size() << std::endl; - std::cout << "front: " << a.front() << std::endl; - std::cout << "back: " << a.back() << std::endl; - std::cout << "[0]: " << a[0] << std::endl; - std::cout << "elems: "; - - // iterate through all elements - for (Array::const_iterator pos=a.begin(); pos DArray; - typedef boost::array IArray; - IArray ia = { { 1, 2, 3, 4, 5, 6 } } ; // extra braces silence GCC warning - DArray da; - da = ia; - da.assign(42); - - return 0; // makes Visual-C++ compiler happy -} - diff --git a/array5.cpp.html b/array5.cpp.html deleted file mode 100644 index 704a38a..0000000 --- a/array5.cpp.html +++ /dev/null @@ -1,87 +0,0 @@ - - -array5.cpp - - - -  - -
    - - array5.cpp - -

    - -

    - - -/* simple example for using class array<>
    */
    -#include <iostream>
    -#include <boost/array.hpp>
    -
    -template <typename T>
    -void test_static_size (const T& cont)
    -{
    -    int tmp[T::static_size];
    -    for (unsigned i=0; i<T::static_size; ++i) {
    -        tmp[i] = int(cont[i]);
    -    }
    -    for (unsigned i=0; i<T::static_size; ++i) {
    -        std::cout << tmp[i] << ' ';
    -    }
    -    std::cout << std::endl;
    -}
    -
    -int main()
    -{
    -    // define special type name
    -    typedef boost::array<float,6> Array;
    -
    -    // create and initialize an array
    -    const Array a = { { 42.42 } };
    -
    -    // use some common STL container operations
    -    std::cout << "static_size: " << a.size() << std::endl;
    -    std::cout << "size:        " << a.size() << std::endl;
    -    std::cout << "empty:       " << std::boolalpha << a.empty() << std::endl;
    -    std::cout << "max_size:    " << a.max_size() << std::endl;
    -    std::cout << "front:       " << a.front() << std::endl;
    -    std::cout << "back:        " << a.back() << std::endl;
    -    std::cout << "[0]:         " << a[0] << std::endl;
    -    std::cout << "elems:       ";
    -
    -    // iterate through all elements
    -    for (Array::const_iterator pos=a.begin(); pos<a.end(); ++pos) {
    -        std::cout << *pos << ' ';
    -    }
    -    std::cout << std::endl;
    -    test_static_size(a);
    -
    -    // check copy constructor and assignment operator
    -    Array b(a);
    -    Array c;
    -    c = a;
    -    if (a==b && a==c) {
    -        std::cout << "copy construction and copy assignment are OK"
    -                  << std::endl;
    -    }
    -    else {
    -        std::cout << "copy construction and copy assignment are BROKEN"
    -                  << std::endl;
    -    }
    -
    -    typedef boost::array<double,6> DArray;
    -    typedef boost::array<int,6> IArray;
    -    IArray ia = { 1, 2, 3, 4, 5, 6 };
    -    DArray da;
    -    da = ia;
    -    da.assign(42);
    -
    -    return 0;  // makes Visual-C++ compiler happy
    -}
    -
    -
    -
    - - diff --git a/doc/array.xml b/doc/array.xml deleted file mode 100644 index 170aca1..0000000 --- a/doc/array.xml +++ /dev/null @@ -1,545 +0,0 @@ - - - - - - Nicolai - Josuttis - - - - 2001 - Nicolai M. Josuttis - - - - Permission to copy, use, modify, sell and distribute this - software is granted provided this copyright notice appears in - all copies. This software is provided "as is" without express or - implied warranty, and with no claim as to its suitability for - any purpose. - - - STL compliant container wrapper for arrays of constant size - - - - Boost.Array - -

    - Introduction - - - - - The C++ Standard Template Library STL as part of the C++ - Standard Library provides a framework for processing algorithms on - different kind of containers. However, ordinary arrays don't - provide the interface of STL containers (although, they provide - the iterator interface of STL containers). - - As replacement for ordinary arrays, the STL provides class - std::vector. However, - std::vector<> provides - the semantics of dynamic arrays. Thus, it manages data to be able - to change the number of elements. This results in some overhead in - case only arrays with static size are needed. - - In his book, Generic Programming and the - STL, Matthew H. Austern introduces a useful wrapper - class for ordinary arrays with static size, called - block. It is safer and has no worse performance than - ordinary arrays. In The C++ Programming - Language, 3rd edition, Bjarne Stroustrup introduces a - similar class, called c_array, which I (Nicolai Josuttis) present - slightly modified in my book The C++ Standard Library - - A Tutorial and Reference, called - carray. This is the essence of these approaches - spiced with many feedback from boost. - - After considering different names, we decided to name this - class simply array. - - Class array fulfills - most but not all of the requirements of "reversible containers" - (see Section 23.1, [lib.container.requirements] of the C++ - Standard). The reasons array is not an reversible STL container is - because: - - No constructors are provided. - Elements may have an undetermined initial value (see ). - swap() has no constant complexity. - size() is always constant, based on the second template argument of the type. - The container provides no allocator support. - - - - It doesn't fulfill the requirements of a "sequence" (see Section 23.1.1, [lib.sequence.reqmts] of the C++ Standard), except that: - - front() and back() are provided. - operator[] and at() are provided. - - -
    - - -
    - - - - - STL compliant container wrapper for arrays of constant size - - T - - - T* - - - const T* - - - std::reverse_iterator<iterator> - - - std::reverse_iterator<const_iterator> - - - T& - - - const T& - - - std::size_t - - - std::ptrdiff_t - - - - size_type - N - - - - - - const array<U, N>& - - std::copy(rhs.begin(),rhs.end(), begin()) - - - - - - iterator - - - const_iterator - - - iterator for the first element - will not throw - - - - - iterator - - - const_iterator - - - iterator for position after the last element - will not throw - - - - - - - reverse_iterator - - - const_reverse_iterator - - - reverse iterator for the first element of reverse iteration - - - - - reverse_iterator - - - const_reverse_iterator - - - reverse iterator for position after the last element in reverse iteration - - - - - - size_type - N - - - bool - N==0 - will not throw - - - size_type - N - will not throw - - - - - - - reference - - size_type - - - - - const_reference - - size_type - - - - i < N - element with index i - will not throw. - - - - - reference - - size_type - - - - - const_reference - - size_type - - - - element with index i - std::range_error if i >= N - - - - - reference - - - const_reference - - N > 0 - the first element - will not throw - - - - - reference - - - const_reference - - N > 0 - the last element - will not throw - - - - const T* - elems - will not throw - - - - - - void - - array<T, N>& - - std::swap_ranges(begin(), end(), other.begin()) - linear in N - - - void - - const T& - - std::fill_n(begin(), N, value) - - - - - T - - - - - - - void - - - array<T, N>& - - - array<T, N>& - - - x.swap(y) - will not throw. - - - - - - - - bool - - - const array<T, N>& - - - const array<T, N>& - - - std::equal(x.begin(), x.end(), y.begin()) - - - - - - - bool - - - const array<T, N>& - - - const array<T, N>& - - - !(x == y) - - - - - - - bool - - - const array<T, N>& - - - const array<T, N>& - - - std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()) - - - - - - - bool - - - const array<T, N>& - - - const array<T, N>& - - - y < x - - - - - - bool - - - const array<T, N>& - - - const array<T, N>& - - - !(y < x) - - - - - - bool - - - const array<T, N>& - - - const array<T, N>& - - - !(x < y) - - - - -
    -
    - -
    - Design Rationale - - There was an important design tradeoff regarding the - constructors: We could implement array as an "aggregate" (see - Section 8.5.1, [dcl.init.aggr], of the C++ Standard). This would - mean: - - An array can be initialized with a - brace-enclosing, comma-separated list of initializers for the - elements of the container, written in increasing subscript - order: - - boost::array<int,4> a = { { 1, 2, 3 } }; - - Note that if there are fewer elements in the - initializer list, then each remaining element gets - default-initialized (thus, it has a defined value). However, - passing no initializer list means that the elements have an - indetermined initial value. - - It has no user-declared constructors. - It has no private or protected non-static data members. - It has no base classes. - It has no virtual functions. - - - - The current implementation uses this approach. However, being - able to have indeterminate initial values is a big drawback. So, - please give me some feedback, how useful you consider this feature - to be. -
    - -
    - Open Issues - - - - - Do we want initializer list support or would the - following be OK?: - - int data[] = { 1, 2, 3, 4 } -boost::array<int,5> x(data); // or boost::array<int,data> x; - - - Could "{ ... }" be used portably instead of "{ - { ... } }" to initialize values? 8.5.1 (11) of the Standard seems - to allow it; however, gcc 2.95.2 prints a warning - message. - - Any way to have determinate initial values and - initializer list support? - - Static_casts for reverse iterator stuff? - - - I'd appreciate any constructive feedback. Please note: I don't - have time to read all boost mails. Thus, to make sure that feedback arrives me, - please send me a copy of each mail regarding this class. -
    - -
    - For more information... - To find more details about using ordinary arrays in C++ and - the framework of the STL, see e.g. - - The C++ Standard Library - A Tutorial and Reference -by Nicolai M. Josuttis -Addison Wesley Longman, 1999 -ISBN 0-201-37926-0 - - - Home Page of Nicolai - Josuttis -
    - -
    - Acknowledgements - - Doug Gregor ported the documentation to the BoostBook format. -
    - - - - diff --git a/index.htm b/index.htm deleted file mode 100644 index 4c91b53..0000000 --- a/index.htm +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - -Array Wrapper Libary - - - - - - - - - - - - - -
    c++boost.gif (8819 bytes)HomeLibrariesPeopleFAQMore
    -

    Array wrapper library

    -

    The header array.hpp provides an STL compliant container wrapper for arrays -of constant size. -

    -

    Revised 14 Mar 2001

    - - - - diff --git a/print.hpp b/print.hpp deleted file mode 100644 index 7ce0a2c..0000000 --- a/print.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/* The following code example is taken from the book - * "The C++ Standard Library - A Tutorial and Reference" - * by Nicolai M. Josuttis, Addison-Wesley, 1999 - * - * (C) Copyright Nicolai M. Josuttis 1999. - * Permission to copy, use, modify, sell and distribute this software - * is granted provided this copyright notice appears in all copies. - * This software is provided "as is" without express or implied - * warranty, and with no claim as to its suitability for any purpose. - */ -#include - -/* print_elements() - * - prints optional C-string optcstr followed by - * - all elements of the collection coll - * - separated by spaces - */ -template -inline void print_elements (const T& coll, const char* optcstr="") -{ - typename T::const_iterator pos; - - std::cout << optcstr; - for (pos=coll.begin(); pos!=coll.end(); ++pos) { - std::cout << *pos << ' '; - } - std::cout << std::endl; -} diff --git a/print.hpp.html b/print.hpp.html deleted file mode 100644 index 2afc947..0000000 --- a/print.hpp.html +++ /dev/null @@ -1,48 +0,0 @@ - - -PRINT_ELEMENTS() - - - -  - -
    - - PRINT_ELEMENTS() - -

    - - - The following code example is taken from the book
    - - The C++ Standard Library - A Tutorial and Reference
    - by Nicolai M. Josuttis, Addison-Wesley, 1999
    - - © Copyright Nicolai M. Josuttis 1999
    -
    - -

    - - -#include <iostream>
    -
    -/* print_elements()
    * - prints optional C-string optcstr followed by
    * - all elements of the collection coll
    * - separated by spaces
    */
    -template <class T>
    -inline void print_elements (const T& coll, const char* optcstr="")
    -{
    -    typename T::const_iterator pos;
    -
    -    std::cout << optcstr;
    -    for (pos=coll.begin(); pos!=coll.end(); ++pos) {
    -        std::cout << *pos << ' ';
    -    }
    -    std::cout << std::endl;
    -}
    -
    -
    - -