Giter Club home page Giter Club logo

flatlib's Introduction

flatlib

Flatten any C++ collection to only not flattenable values. That's it.

Library provides flat_view which is both a range and an iterator in flattened manner over any type of range provided by the user.

std::list<std::vector<int>> numbers{ {1,2,3}, {4,5,6,7} };
for (int n : flatlib::flat(numbers)) {
	std::cout << n << '\n';
}
// Initialize 3x3 matrix with consecutive numbers
std::array<std::array<int, 3>, 3> m;
auto flat_matrix = flatlib::flat(m);
std::iota(flat_matrix.begin(), flat_matrix.end(), 0);

Requires C++20.

Rules

Each rule is marked if it's implemented

  • flat_view is only a non-owning view: it only accepts lvalue references
  • Flattened range with only one layer like flat_view<std::vector<int>> preserves iterator category
  • Flattened at least bidirectional range is bidirectional
  • Flattened at least forward range is forward
  • Flattened at least input range is input
  • Flattened collection of std::array is contigious
  • Supports C++20 ranges semantics
  • Supports C++17 iterator semantics

for definitions of input, forward, bidirectional and contigious from C++ standard libary.

flatlib's People

Contributors

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