Giter Site home page Giter Site logo

any_of's Introduction

any_of

Introduction

A simple library that lets you compare a value against many values using one operator.

E.g.

x == srp::any_of(1, 2, 3, 4);

is equivalent to:

x == 1 || x == 2 || x == 3 || x == 4;

Besides any_of, library also provides none_of, all_of and one_of. All of them override operator== in an expected way:

x == srp::none_of(1, 2, 3) is equivalent to x != 1 && x != 2 && x != 3 x == srp::all_of(1, 2, 3) is equivalent to x == 1 && x == 2 && x == 3 x == srp::one_of(1, 2, 3) is equivalent to (x == 1) + (x == 2) + (x == 3) == 1

Custom functions

In addition to these functions, you can define your own functions with custom behaviour using srp::make_custom_of. It is a function template taking operator structs defining operators that should be available and return a lambda that can be called just like srp::any_of. Operator struct should define an operator as a friend function. Library provides srp::EqOp that provides operator== and srp::NeqOp that provides operator!=.

any_of's People

Contributors

serpent7776 avatar

Stargazers

Paweł Syska avatar

Watchers

James Cloos 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.