Skip to content

Instantly share code, notes, and snippets.

/* This demonstrates that gcc or clang can incur a loss of precision of
variables without warning. Compile and run this program to see for yourself.
You may need to use `-std=c++11` depending on your compiler. Notice that the
size of some of the variables change. If you compile this with `-Wconversion`
then the compiler will properly complain about this conversion.
`-Wconversion` does not fall under `-Wall` or `-Wextra`. You must also use
`-Wconversion` to get the warning message. */
#include <iostream>
#include <stdint.h>
@hershal
hershal / struct-keying.cpp
Created September 7, 2016 07:53
an unordered map keyed with a struct
/* This is a demonstration which uses a struct to store/fetch values from
an unordered map.
*/
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
enum container_material { plastic, metal, materialCount };