https://github.com/pierrechevalier83/signed_size
A header only utility function for getting the size of a container as a signed type
https://github.com/pierrechevalier83/signed_size
cpp cpp11 cpp14 header-only modern-cpp signed utility
Last synced: about 1 year ago
JSON representation
A header only utility function for getting the size of a container as a signed type
- Host: GitHub
- URL: https://github.com/pierrechevalier83/signed_size
- Owner: pierrechevalier83
- Created: 2016-12-05T03:10:35.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-21T09:54:36.000Z (over 9 years ago)
- Last Synced: 2025-02-09T13:29:15.695Z (over 1 year ago)
- Topics: cpp, cpp11, cpp14, header-only, modern-cpp, signed, utility
- Language: C++
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# signed_size
A header only utility function for getting the size of a container as a signed type.
# Motivation
In a nutshell:
It allows to use old-style for loops without triggering sign comparison warnings:
```
for (int i = 0; i < signed_size(container); ++i) { ... }
for (int64_t i = 0; i < signed_size(big_container); ++i) { ... }
```
Check out [this article](https://pierrec.tech/articles/code/signed_vs_unsigned_int.html) for a detailed explanation about the motivation.
# Build
- `mkdir build`
- `cd build`
- `cmake ..`
- `make`
- `make test`