471,119 Members | 1,449 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,119 software developers and data experts.


When I do:

static const ios_base::openmode emptyMode = (

the complier says:
io.hpp:43: field initializer is not constant


Jul 19 '05 #1
1 4316
Marc Schellens <m_*********@hotmail.com> wrote:
the complier says:
io.hpp:43: field initializer is not constant

As a first guess I would pretend that the initializer is not constant...
Maybe I should elaborate a little bit: there is no requirement that the open
mode is one of the built-in integral types. It can be an enumeration (I think
it is required to be an integral type, however; ie. it cannot be, for example,
'std::bitset<6>'). For enumerations the bitwise logic operations are not
automatically defined and it requires overloading them to turn the enumeration
into a bitmask. Overloading involves function calls and the result of a
function call is never a constant expression as is required in your example.

I agree that your expression should be a constant expression ie. that eg.
inline functions depending strictly only on their arguments should capable of
producing constant expression if their arguments are all constant expressions.
However, the current C++ specification has no such provision.
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
Phaidros eaSE - Easy Software Engineering: <http://www.phaidros.com/>
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Brandon McCombs | last post: by
10 posts views Thread by Dave O'Hearn | last post: by
10 posts views Thread by Steve | last post: by
12 posts views Thread by zhushenli | last post: by
103 posts views Thread by Steven T. Hatton | last post: by
reply views Thread by Greg Stoch | last post: by
4 posts views Thread by Ben Pope | last post: by
1 post views Thread by meLlamanJefe | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.