Giter Site home page Giter Site logo

const_types's Introduction

const_types: Const correctness made easier

The importance of const correctness is a well known fact. const_types.h is a simple header file containing a bunch of typedefs and (for C++) one macro (cauto). It's only purpose is to make C/C++ source code more concise.

For instance the following code segment

#include <const_types.h>

int ld2i( cldouble d )
{ return int(d); }

int main()
{
  cint     a1= -5;
  cuint    b1=  6;
  cldouble c1= 3.14;

  cuint64_t   d1= 345;

  cauto  e1= ld2i( c1 );
  cauto &f1= b1;
}

is equivalent to

#include <cstdint>

int ld2i( const long double d )
{ return int(d); }

int main()
{
  const int          a1= -5;
  const unsigned int b1=  6;
  const long double  c1= 3.14;

  const uint64_t     d1= 345;

  auto const  e1= ld2i( c1 );
  auto const &f1= b1;
}

The following table summarizes all supported types.

typedef meaning
cbool const bool
cchar const char
cshort const short
cushort const unsigned short
cint const int
cuint const unsigned int
clong const long
culong const unsigned long
cllong const long long
cullong const unsigned long long
csize_t const size_t
cfloat const float
cdouble const double
cldouble const long double
cintmax_t const intmax_t
cuintmax_t const uintmax_t
cint8_t const int8_t
cuint8_t const uint8_t
cint16_t const int16_t
cuint16_t const uint16_t
cint32_t const int32_t
cuint32_t const uint32_t
cint64_t const int64_t
cuint64_t const uint64_t
cint_least8_t const int_least8_t
cuint_least8_t const uint_least8_t
cint_least16_t const int_least16_t
cuint_least16_t const uint_least16_t
cint_least32_t const int_least32_t
cuint_least32_t const uint_least32_t
cint_least64_t const int_least64_t
cuint_least64_t const uint_least64_t
cint_fast8_t const int_fast8_t
cuint_fast8_t const uint_fast8_t
cint_fast16_t const int_fast16_t
cuint_fast16_t const uint_fast16_t
cint_fast32_t const int_fast32_t
cuint_fast32_t const uint_fast32_t
cint_fast64_t const int_fast64_t
cuint_fast64_t const uint_fast64_t

const_types's People

Contributors

claasbontus 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.