std-byte Questions

10

Solved

If it exists, is there header file to include? This code results in a compilation error: int main() { byte b = 2; // error }
Corny asked 16/11, 2013 at 22:24

3

Solved

C++17 introduces the std::byte type. A library type that can (supposedly) be used to access raw memory, but stands separate from the character types and represents a mere lump of bits. So far so g...
Vallombrosa asked 17/7, 2017 at 5:46

1

Solved

C++ has a lot of types that vaguely describe the same thing. Assuming that we are compiling for an architecture where a byte is 8-bit, all of the following types are vaguely similar: std::byte std...
Elk asked 13/9, 2023 at 13:44

4

Solved

I'm trying to read a file in binary format into a std::vector<std::byte> std::ifstream fStream(fName, std::ios::binary); std::vector<std::byte> file_content((std::istreambuf_iterato...
Como asked 24/2, 2018 at 16:22

2

Solved

std::byte is an abstraction that is supposed to provide a type safe(r) access to regions of memory in C++, starting with the new standard 17. However, it's declared this way according to http://en....
Churr asked 12/6, 2017 at 20:27

1

Solved

In CPP Reference it is stated that: std::byte is a distinct type that implements the concept of byte as specified in the C++ language definition. Like char and unsigned char, it can be used to acc...
Thereupon asked 17/8, 2023 at 9:13

2

Solved

std::byte is defined in C++17 as: enum class byte : unsigned char {}; I'm currently stuck at using C++14, and I wonder if I add the same definition in C++14 (in some non-std namespace, along with ...
Offshore asked 9/8, 2023 at 9:17

0

Consider an unsigned char v that goes through a series of bit-wise operations with the result stored back to v. Under the hood, it is integer promoted once, undergoes a series of operations, and th...
Congregation asked 10/5, 2023 at 14:9

1

I really like std::byte as a distinct type that implements the concept of byte as specified in the C++ language definition. What I don't like is the fact that modern C++ compilers will produce less...
Linguini asked 14/1, 2023 at 20:46

2

Solved

The following code does not compile in C++20 #include <iostream> #include <cstddef> int main(){ std::byte b {65}; std::cout<<"byte: "<<b<<'\n';// Missing...
Elzaelzevir asked 31/8, 2021 at 7:13

2

I'd like to use C++17's std::byte type if it's available, and fall back to using unsigned char if not, i.e. something along the lines of #include <cstddef> namespace my { #if SOMETHING usin...
Murton asked 12/6, 2017 at 18:58

2

Solved

I'm trying to learn new features/gimmicks of c++17, but then I got to std::byte and for some unknown reason I can't seem to be able to compile even most basic "hello world" type program with the ty...
Seventieth asked 1/7, 2019 at 22:57

2

Solved

C++17 introduced a new type, std::byte, so now we finally have a first-class citizen type to represent bytes in memory. Besides being a novelty in the standard, the C++ rules for object creation, s...
Bourse asked 8/10, 2019 at 14:18

3

Solved

std::byte is a new type in C++17 which is made as enum class byte : unsigned char. This makes impossible to use it without appropriate conversion. So, I have made an alias for the vector of such ty...
Pedology asked 11/9, 2017 at 7:54

1

Solved

Now that c++17 has std::byte, I was looking for a way to convert code that reads files to char into code that reads files into byte. A file contains bytes, not a bunch of integers. Then I read th...
Assai asked 24/11, 2017 at 23:34

1

Solved

C++ (and C) strict aliasing rules include that a char* and unsigned char* may alias any other pointer. AFAIK there is no analogous rule for uint8_t*. Thus my question: What are the aliasing rules...
Mitchel asked 21/4, 2017 at 20:40

1

Solved

Reading Herb Sutter's blog post about the most recent C++ standard meeting, it noticed that std::byte was added to C++17. As an initial reading, I have some concerns since it uses unsigned char so ...
Christian asked 31/3, 2017 at 14:34
1

© 2022 - 2025 — McMap. All rights reserved.