Skip to content

Instantly share code, notes, and snippets.

@odeblic
Created August 2, 2017 14:51
Show Gist options
  • Save odeblic/2f253dc50d3abeb336a4f33a4eb53761 to your computer and use it in GitHub Desktop.
Save odeblic/2f253dc50d3abeb336a4f33a4eb53761 to your computer and use it in GitHub Desktop.
Representations of bytes
#include <iostream>
#include <cstddef>
void action(char arg)
{
std::cout << "char arg -> " << (int)arg << "\n";
}
void action(signed char arg)
{
std::cout << "signed char arg -> " << (int)arg << "\n";
}
void action(unsigned char arg)
{
std::cout << "unsigned char arg -> " << (int)arg << "\n";
}
void action(std::byte arg)
{
std::cout << "byte arg -> " << (int)arg << "\n";
}
int main()
{
char c{};
signed char sc{};
unsigned char uc{};
std::byte b{};
action(c);
action(uc);
action(sc);
action(b);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment