"Steven C." <no****@xxx.com> wrote in message
news:mV******************@twister.socal.rr.com...
"Gianni Mariani" <gi*******@mariani.ws> wrote in message
news:bl********@dispatch.concentric.net...
Steven C. wrote: "Larry Lindsey" <gt*****@prism.gatech.edu> wrote in message
news:bl**********@news-int.gatech.edu...
Is there a better way of defining a large array other than malloc? I'm
looking to declare an array of bool at a length of up to 250000000. Thanks,
Larry
__________________________________________________ _____
Since a bool hold is only 1 or 0 I use a long to store 32 bools and then
you could malloc (or new) 7812500 longs. It would be trival to wirte a
class to do this.
I believe vector<bool> is a special case for this.
__________________________________________
Really that would be great.
Not 'would', but 'is' :-)
================================================== =======
ISO/IEC 14882:1998(E)
23.2.5 Class vector<bool>
1 To optimize space allocation, a specialization of vector for
bool elements is provided:
namespace std {
template <class Allocator> class vector<bool, Allocator> {
public:
// types:
typedef bool const_reference;
typedef (implementation defined) iterator; // See 23.1
typedef (implementation defined) const_iterator; // See 23.1
typedef (implementation defined) size_type; // See 23.1
typedef (implementation defined) difference_type;// See 23.1
typedef bool value_type;
typedef Allocator allocator_type;
typedef (implementation defined) pointer;
typedef (implementation defined) const_pointer
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator>
const_reverse_iterator;
// bit reference:
class reference {
friend class vector;
reference();
public:
~reference();
operator bool() const;
reference& operator=(const bool x);
reference& operator=(const reference& x);
void flip(); // flips the bit
};
[member function descriptions omitted for brevity -- MKW]
2 reference is a class that simulates the behavior of references
of a single bit in vector<bool>.
================================================== =======
HTH,
-Mike