Topic: N2369 library defect: Omissions in constexpr usages


Author: =?iso-8859-1?q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Sat, 25 Aug 2007 09:35:02 CST
Raw View
1) The member function bool array<T,N>::empty() const should be a
constexpr because
   this is easily to proof and to implement following it's operational
semantics defined by
   Table 87 (Container requirements) which says: "a.size() == 0".
2) The member function bool bitset<N>::test() const must be a
constexpr (otherwise
   it would violate the specification of constexpr
bitset<N>::operator[](size_t) const,
   because it's return clause delegates to test()).
3) I wonder how the constructor bitset<N>::bitset(unsigned long) can
be declared as
   a constexpr. Current implementations usually have no such bitset
c'tor which would
   fulfill the requirements of a constexpr c'tor because they have a
non-empty c'tor
   body that typically contains for-loops or memcpy to compute the
initialisation. What
   have I overlooked here?

Proposed resolutions:

1) In the class template definition of [array]/p. 3 replace

bool empty() const;

by

constexpr bool empty() const;

2) In the class template definition of [template.bitset]/p. 1 replace

bool test(size_t pos ) const;

by

constexpr bool test(size_t pos ) const;

and in [bitset.members] replace

bool test(size_t pos ) const;

by

constexpr bool test(size_t pos ) const;

3) ---

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.comeaucomputing.com/csc/faq.html                      ]