Skip to content

Latest commit

 

History

History
39 lines (36 loc) · 959 Bytes

README.md

File metadata and controls

39 lines (36 loc) · 959 Bytes

primitive

C++ primitive data type wrapper

Features

  • Comparsion chaining
  • STL support for std::ostream, std::istream, std::hash
  • Member casting functions such as to_s, to_ws, cast<T>, ...
  • Types are more restrictive than primitives in ISO C++, i.e. i64_t var = ui64_t(0) will error

Usage

#include "primitive.h"

using namespace primitive;
using namespace primitive::literals;

template <class T>
struct Point
{
    T x, y;
};
template <class T>
struct Size
{
    T width, height;
};

int main()
{
    Size<i64_t> window{640_i64, 480_i64};
    Point<i64_t> pixel{100_i64, 100_i64};
    // Check if point is inbetween the window, if so, print the points location
    if (0_i64 < pixel.x < window.width && 0_i64 < pixel.y < window.height)
    {
        auto x = pixel.x.to<d_t>().to_s();
        std::cout << "pixel.x=" << x << " pixel.y=" << pixel.y << std::endl;
    }
}

Installation

Just copy the header into your project.