 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Daniel Krügler Guest
|
Posted: Tue Aug 16, 2005 1:32 pm Post subject: Extension of tuple interface for std::bitset |
|
|
After reading about the current application of std::tr1::tuple_size in
http://www2.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf
I found that it should should result in well-formed code if one of the for
the following class templates are used as template arguments:
std::pair<typename, typename>
std::tr1::tuple<...>
std::tr1::array<typename, size_t>
I suggest, that
template<size_t N> class bitset
should also provide a similar tuple interface. I propose to add the
following clauses:
"Tuple interface to class template bitset [tr.bitset.tuple]
tuple_size<bitset::value
1 Return type: integral constant expression.
2 Value: N
tuple_element<I, bitset::type
3 Requires:0 <= I < N. The program is ill-formed if I is out of bounds.
4 value: The type bool.
template
5 Requires: 0 <= I < N. The program is ill-formed if I is out of bounds.
6 Returns: A reference to the Ith element of a, where indexing is
zero-based.
template
7 Requires: 0 <= I < N. The program is ill-formed if I is out of bounds.
8 Return type: bool.
9 Returns: The value of the Ith element of a, where indexing is zero-based."
To my opinion std::bitset
std::tr1::array<typename, size_t> as the static analogon of
std::vector<bool> compared to std::vector<T != bool>.
Another argument is, that std::bitset<size_t> has no compile-time
accessor for its template argument (The member function size() is a
runtime function).
I understand that their might exist dissenting votes to this proposals.
One major argument, I can think of, is that vector<bool> does not
fulfill the C++ Conatiner requirements, and I have to confess, that this
partially is true for std::bitset, too, concerning the tuple-interface,
namely that all other tuple classes do return **real** references to
the underlying tuple elements, while std::bitset<N> does not.
So a minimum proposal would be that there shall exist a specialization
tuple_size<bitset.
Greetings from Bremen,
Daniel Krügler
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|