Coder Social home page Coder Social logo

types_list's Introduction

types_list

Tests (Ubuntu) Tests (Mac) Tests (Windows) License Compiler explorer

A types_list template object for C++17 and later.

Features

  • C++17
  • Header-only
  • Dependency-free
  • Construction of compile-time types lists
  • Inter-operate between types lists and std::tuple
  • Iterate over types in a types list at run-time or compile-time
  • Making a types list:

    // Making a types list directly
    using List1 = types_list::TypesList<Type1, Type2, std::string, int>;
    
    // Making a types list by insertion
    using List2 = List1::InsertFront<Type3>::InsertBack<double>;
    
    // Making a types list by concatenation
    using List3 = List1::Concatenate<List2>;
  • Inter-operating with std::tuple

    using Tuple1 = std::tuple<int, float, double>;
    
    // Making a types list from a std::tuple type
    using TupleAsList = types_list::TupleList<Tuple1>;
    
    // Making a std::tuple type from a types list
    using Tuple2 = TupleAsList::Types;
    
    // Check that everything worked...
    static_assert (std::is_same_v<Tuple1, Tuple2>);
  • Iterating over a types list

    // Print the epsilon value for different floating point types:
    using List = types_list::TypesList<float, double, long double>;
    types_list::forEach<List>([] (auto typeIndex) {
        using TypeAtIndex = List::AtIndex<typeIndex>;
        std::cout << std::numeric_limits<TypeAtIndex>::epsilon() << std::endl;
    });

Integration

You should add required file types_list.hpp.

You can also use something like CPM which is based on CMake's Fetch_Content module.

CPMAddPackage(
    NAME types_list
    GITHUB_REPOSITORY jatinchowdhury18/types_list
    GIT_TAG x.y.z # Where `x.y.z` is the release version you want to use.
)

Compiler compatibility

  • Clang/LLVM >= 9
  • Visual Studio >= 2019
  • Xcode >= 11
  • GCC >= 9

License

types_list is licensed under the MIT license. Enjoy!

types_list's People

Contributors

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