473,467 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ios::openmode

When I do:

static const ios_base::openmode emptyMode = (
~(ios_base::app|
ios_base::ate|
ios_base::binary|
ios_base::in|
ios_base::out|
ios_base::trunc));

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

why?
thanks,
marc

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


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Brandon McCombs | last post by:
This may be the wrong group but I didn't see anything for VC++ so I'm trying here. I have a C++ book by Deitel and Deitel that says I can use fstream File("data.dat", ios::in | ios::out |...
10
by: Dave O'Hearn | last post by:
I want to open a file for both reading and writing, but when I do "ios::in|ios::out" with an fstream, it creates the file if it doesn't already exist. I don't like that last part. C's fopen has the...
10
by: Steve | last post by:
Hi, I'm trying to read a binary file into a buffer: std::ifstream ifs(fileName, std::ios::in|std::ios::binary); if (!ifs) return; ifs.seekg(0,std::ios::end); int len = ifs.tellg();...
12
by: zhushenli | last post by:
Hello all, In c,i can open a file with argv append, How to append context to a FILE in c++ fstream? Thanks! Regards, Davy
103
by: Steven T. Hatton | last post by:
§27.4.2.1.4 Type ios_base::openmode Says this about the std::ios::binary openmode flag: *binary*: perform input and output in binary mode (as opposed to text mode) And that is basically _all_ it...
0
by: Greg Stoch | last post by:
Hi, How to check if the stream is opened in binary mode? Suppose, we are about creating "bool is_binary(iostream &)" function for such an assertion, working like this: .... ofstream os...
4
by: Ben Pope | last post by:
Hi, The following code compiles with Comeau Online, but not MSVC 8.0. Comeau issues a warning that return 0 is unreachable. #include <sstream> #include <iostream>
15
by: Gan Quan | last post by:
I'm writing a c++ program that has many (100+) threads read/write files simultaneously. It works well if not considering the efficiency. The file i/o seems to be the bottleneck. This is my code...
1
by: meLlamanJefe | last post by:
I have a set of values that need to be output to a text file. The output includes both text and numbers so I'd like to line up the floating point numbers on the list so it is easy to read. The output...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.