Giter Site home page Giter Site logo

distance's Introduction

Type-safe distance library

Changelog

  • v1.0 - First release

Overview

This library provides a distance template class that is loosely modeled after std::chrono::duration. The main difference here is that there is no analog to std::chrono::clock to provide a default granularity so you have to choose an explicit precision when declaring your variables.

You can specialize this class for the underlying storage type; most predefined specializations (centimeters, meters, etc) use a 64-bit signed integer.

There are specializations for the following units:

  • SI
    • angstrom
    • nanometers
    • micrometers (alias: microns)
    • millimeters
    • centimeters
    • decimeters
    • meters
    • decameters
    • hectometers
    • kilometers
  • MURICA
    • twips
    • thous
    • barleycorns
    • inches
    • hands
    • feet
    • yards
    • chains
    • furlongs
    • miles
    • leagues
  • Misc
    • cubics
    • attoparsecs
    • beard_seconds
    • light_seconds

Installation

Copy include/fraca7 somewhere in your include path (there's a single distance.hpp file in there)

Example usage

#include <iostream>
#include <fraca7/distance.hpp>

int main(int, char*[]) {
  fraca7::centimeters d(25);

  auto i = fraca7::distance_cast<fraca7::inches>(d);
  auto b = fraca7::distance_cast<fraca7::barleycorns>(d - i);

  std::cout << "25cm are " << i.count() << " inches and " << b.count() << " barleycorns" << std::endl;

  return 0;
}

distance's People

Contributors

fraca7 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.