473,434 Members | 1,854 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,434 software developers and data experts.

Can I access single bits from a vector<bitset<N>>?

14
I want to know if this is right:

Expand|Select|Wrap|Line Numbers
  1. if (f%2 == 0) {
  2. bitset<8> bytes;
  3. bytes[0] = node[0][0];
  4. bytes[1] = go[0][0];
  5. bytes[2] = go[0][1];
  6. bytes[3] = go[0][2];
  7. bytes[4] = node[1][0];
  8. bytes[5] = go[1][0];
  9. bytes[6] = go[1][1];
  10. bytes[7] = go[1][2];
  11. out << ios_base::hex << bytes;
  12. node.clear(); go.clear();
  13. }
May 1 '16 #1

✓ answered by weaknessforcats

I can't tell from the code what you want to do. Does the code even compile?

A bitset<> allows you to access and change the state of any bit in the bitset.

You can have a vector of bitsets.

The vector implements an array. The bitset would be an array element. You can use bitset member functions with the array element. So yes, you can access individual bits in a bitset that is a vector element.

2 1236
weaknessforcats
9,208 Expert Mod 8TB
I can't tell from the code what you want to do. Does the code even compile?

A bitset<> allows you to access and change the state of any bit in the bitset.

You can have a vector of bitsets.

The vector implements an array. The bitset would be an array element. You can use bitset member functions with the array element. So yes, you can access individual bits in a bitset that is a vector element.
May 2 '16 #2
aunk
14
Thank you, I think I found a work around.
May 2 '16 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: mrT | last post by:
Hi, My latest web project includes loads of user-customisable features, lots of which are on/off values. Currently I'm storing each one of the 15 or so properties in tinyint fields, as 1s or 0s....
59
by: riva | last post by:
I am developing a compression program. Is there any way to write a data to file in the form of bits, like write bit 0 then bit 1 and then bit 1 and so on ....
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
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.