473,385 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

bitset variable

Dear friends,
i am in mess with bitset again. i have managed to write a messy code
which checks the machine bitsize and then wants to do a bitflip. here
is the code:
int bit;
if (strncmp(sysptr, "i686",4)==0)
{
bit=32;
}
......
bitset<32i (0);
....etc.
where in bitset is equal to bit,which is 32. but i tried to write the
bitset as *bitset<biti (0);*(i.e. to read the bit)
where its giving the error:error: ‘bit’ cannot appear in a constant-
expression
can you tell me a way to make that possible?
Jul 10 '08 #1
2 1516
rudra wrote:
Dear friends,
i am in mess with bitset again. i have managed to write a messy code
which checks the machine bitsize and then wants to do a bitflip. here
is the code:
int bit;
if (strncmp(sysptr, "i686",4)==0)
{
bit=32;
}
......
bitset<32i (0);
....etc.
where in bitset is equal to bit,which is 32. but i tried to write the
bitset as *bitset<biti (0);*(i.e. to read the bit)
where its giving the error:error: ‘bit’ cannot appear in a constant-
expression
can you tell me a way to make that possible?
You can't. Template (integer) arguments must be compile time constants.

--
Ian Collins.
Jul 10 '08 #2
In article <1efb223b-6b78-40f7-b4f7-8f7a34c1adb2
@w7g2000hsa.googlegroups.com>, bn********@gmail.com says...

[ ... create a bitset where the size isn't a compile-time constant ]
can you tell me a way to make that possible?
Boost Dynamic Bitset.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 10 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hunter Hou | last post by:
Hello, I have this very simple program, but it can't be compiled. What's wrong here? thanks, hunter #include <iostream>
2
by: shaun roe | last post by:
As a follow up to my question about STL and bitset<64> I'd like to share a quirk (bug?) about unsigned long long support and the bitset. I'm using gcc 3.2 on linux or gcc 3.3 on mac, the answer is...
2
by: Michal Wyrebski | last post by:
Hello, I was thinking how is the fastest and the best way of passing bitset variable to some function. Only one method came to my mind. It's about passing converted value: #v+ void...
5
by: Artemis Fowl | last post by:
when i used bitset<> to accept data from the user, much to my surprise, i got the wrong answer. After a bit of fiddling, figured out that the data being entered was being consumed in reverse. I...
2
by: ma740988 | last post by:
Given an unsigned int variable that's part of a composite type struct test { unsigned int mask; }; Assume 4 bytes for unsigned int. In one function, I'd like to set any bit or combination...
6
by: zacariaz | last post by:
The subject isnt very clear, but ill do my best to explain. In a class in need a bitset which size is defined by the constructor, e.g. something like this: class Example { std::bitset<?>Bs;...
4
by: Sarath | last post by:
>From the documentation of MSDN, it is saying that bitset is not a STL container Unlike the similar vector<boolClass, the bitset class does not have iterators and is not an Standard Template...
2
by: arnuld | last post by:
i am confused on some aspects of bitset class: /* C++ Primer 4/e * chapter 3 * * exercise 3.23 * */ #include <iostream>
5
by: swcamry | last post by:
class bitset::reference { friend class bitset; reference(); // no public constructor public: ~reference(); operator bool () const; //...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.