GithubHelp home page GithubHelp logo

yowidin / constexpr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elbeno/constexpr

0.0 0.0 0.0 109 KB

Experiments with constexpr

License: MIT License

Shell 0.04% C++ 97.68% Python 1.14% CMake 1.13%

constexpr's Introduction

Experiments with constexpr

Everything (with the exception of noted functions) is written in C++11 constexpr style for maximum compatibility.

All functions are within the cx namespace.

This code is distributed under the MIT license. See LICENSE for details.

Math functions

  • abs, fabs
  • sqrt, cbrt, hypot
  • exp, log, log10, log2
  • sin, cos, tan
  • asin, acos, atan, atan2
  • floor, ceil, trunc, round (long double variants require C++14)
  • fmod, remainder (long double variants require C++14)
  • fmin, fmax, fdim
  • sinh, cosh, tanh
  • asinh, acosh, atanh
  • pow
  • erf

String hashing

  • fnv1, fnv1a
  • murmur3_32
  • md5
  • sha256

Utility functions

  • strlen
  • strcmp
  • endianswap
  • counter: returns monotonically increasing integers with each call (within a given translation unit)

Random number generation

  • cx_pcg32: a macro that returns a different random uint32_t with each call
  • cx_guidgen: a macro that generates a different random GUID with each call

String encryption

String encryption uses std::make_index_sequence therefore requires C++14.

  • cx_make_encrypted_string: a macro that encrypts a string literal, with a runtime conversion to plaintext std::string

Arrays

Arrays use std::make_index_sequence therefore require C++14.

  • array<type, size>: a constexpr-friendly array type
  • make_array: create an array from e.g. a string literal
  • transform: like std::transform but works on constexpr arrays
  • reverse
  • sort: an implementation of mergesort (stable)
  • partition: a stable partition (but use count_if to obtain the partition point)

Algorithms (including Numeric Algorithms)

  • accumulate: like std::accumulate but works on constexpr arrays

Similarly:

  • all_of, any_of, none_of
  • count, count_if
  • find, find_if, find_if_not`
  • equal, mismatch
  • find_first_of
  • adjacent_find
  • search, search_n
  • inner_product

constexpr's People

Contributors

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