C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Extension of tuple interface for std::bitset

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Daniel Krügler
Guest





PostPosted: Tue Aug 16, 2005 1:32 pm    Post subject: Extension of tuple interface for std::bitset Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.