Skip to content

fpena2/filter_cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

filter_cpp

This project is a C++ implementation inspired by Rust's filter functionality.

Getting Started

Prerequisites

  • A C++ compiler supporting C++14 or later.

  • CMake for build configuration (optional but recommended).

Building the Project

  1. Clone the Repository:

    git clone https://github.com/fpena2/filter_cpp.git
    cd filter_cpp
  2. Build and run tests

    ./build.sh

Usage

The filter function allows for processing elements in a collection based on a specified predicate. Here's an example of how to use it:

#include "filter.h"
#include <vector>
#include <iostream>

int main() {
    std::vector<int> numbers = {1, 2, 3, 4, 5};
    auto is_even = [](int n) { return n % 2 == 0; };

    auto result = filter(numbers, is_even);

    for (int n : result) {
        std::cout << n << std::endl; // Outputs: 2 4
    }

    return 0;
}

About

Rust-like filters in C++

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors