Giter Club home page Giter Club logo

generic's Introduction

AM generic

Header-only collection of generic programming tools for C++11.

Note: All classes and functions are work in progress. Interfaces are still likely to change over time and documentation is limited to some comments so far.

Quick Overview

Classes

integer_sequence

static integer sequence needed for variadic initialization/'exploding' something similar (and most likely better engineered) will be in the C++14 standard library

cached_function

std::function - like wrapper with return value cache

tuple_hash

xors std::hash values of tuple arguments together

Type Traits

all

maps logical AND over a variadic sequence of type traits modeled on std::integral_constant<bool,.>

any

maps logical OR over a variadic sequence of type traits modeled on std::integral_constant<bool,.>

Functions

make_function_composition

composes multiple function objects into one

make_application_chain

chains calls to 'apply(f_i, args...)' for multiple function objects

make_uniform

returns a copy of an object initialized with n times the same value

make_generate

returns a copy of an object initialized with n results obtained by n calls to a generator object

make_copy_elems

returns a copy of an object initialized with n values obtained from n subscript calls (with indices 0...n-1) to a source object

apply(function object, tuple<arguments...>)

explodes tuple arguments into function arguments

map(function object, tuple<arguments...>)

applies a function object to each argument of a tuple of arguments
returns a tuple of results
map(f, {x1,x2,...,xn}) -> {f(x1),f(x2),...,f(xn)}

map(tuple<function_objects...>, arguments...)

applies each function object in a tuple to a series of arguments
returns a tuple of results
map({f1,f2,...,fn}, x1,x2,...,xm) -> {f1(x1,...,xm),...,fn(x1,...,xm)}

zip_map(tuple<function_objects...>, tuple<arguments...>)

applies each function_object to each argument 1-by-1
returns a tuple of results
zip_map({f1,f2,...,fn}, {x1,x2,...,xn}) -> {f1(x1),f2(x2),...,fn(xn)}

for_each_arg(function_object, tuple<arguments...>)

applies a function object to each argument in a tuple of arguments
discards the results and returns void
for_each_arg(f, {x1,x2,...,xn}): {f(x1); f(x2); ...; f(xn);}

for_each_function(tuple<function...>, arguments...)

applies each function object to all arguments in turn
discards the results and returns void
for_each_function({f1,f2,...,fn}, x1,x2,...,xm): {f1(x1,...,xm); ...; fn(x1,...,xm);}

zip_for_each(tuple<function_objects...>, tuple<arguments...>)

applies each function object to each argument 1-by-1
discards the results and returns void
zip_for_each({f1,f2,...,fn}, {x1,x2,...,xn}) {f1(x1); f2(x2); ...; fn(xn);}

Requirements

  • variadic templates
  • template aliases
  • std::tuple
  • std::array
  • std::unordered_map
  • <chrono>
  • <type_traits>

tested with g++ {4.7.2, 5.4, 7.2}, clang++ 5.0.2

generic's People

Contributors

muellan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

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