Giter Site home page Giter Site logo

rx-ranges's People

Contributors

hazurl avatar kijewski avatar saraedum avatar simonask avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rx-ranges's Issues

Complete exception safety and noexcept hygiene

Currently, many functions are marked noexcept, despite potentially calling user-provided functions that may throw. The right thing to do is to add noexcept(noexcept(...)) syntax in those places.

The drawback is that it uglifies the code pretty significantly.

There are also probably places where unconditional noexcept can be safely added.

Why is uniq a sink?

I would expect it to work like

RX_OPTIONAL<output_type> last_value;

uniq(…) {
    last_value.emplace(input.get());
    input.next();
}

constexpr void next() {
    while (!input.at_end()) {
        auto&& next_value = input.get();
        input.next();
        if (!eq(*last_value, next_value)) {
            last_value.emplace(std::forward<decltype(next_value)>(next_value));
            return;
        }
    }
    last_value.reset();
}

constexpr output_type get() const {
    return last_value;
}

VS2017 won't compile without Conformance Mode

As in the title. Not sure if can be marked as bug, but at least it's worth mentioning in the requirements.

Example Code and Console Output

#include "pch.h"
#include "ranges.hpp"
#include <iostream>
#include <vector>

template <typename Type>
struct Point {

    Point(Type x, Type y) noexcept
        : X { x }
        , Y { y }
    {
    }

    Type X;
    Type Y;
};

int main()
{
    std::vector<Point<int>> vec;
    vec.emplace_back(1, 2);
    vec.emplace_back(2, 3);
    vec.emplace_back(3, 4);

    auto transformed = vec
        | rx::filter([](Point<int> point) { return point.X == 3; })
        | rx::transform([](Point<int> point) { return point.X; })
        | rx::to_vector();

    for (auto x : transformed) {
        std::cout << x << '\n';
    }
}
1>c:\users\tomek\source\repos\consoleapplication7\consoleapplication7\ranges.hpp(1476): error C2133: 'vec': unknown size
1>c:\users\tomek\source\repos\consoleapplication7\consoleapplication7\ranges.hpp(235): note: see reference to function template instantiation 'auto rx::to_vector::operator ()<LHS>(R &&) const' being compiled
1>        with
1>        [
1>            LHS=rx::transform<main::<lambda_5eaf32db83d37af66b6c17510f1a5e05>>::Range<Inner>,
1>            R=rx::transform<main::<lambda_5eaf32db83d37af66b6c17510f1a5e05>>::Range<Inner>
1>        ]
1>c:\users\tomek\source\repos\consoleapplication7\consoleapplication7\ranges.hpp(1476): error C2512: 'std::vector<remove_cv<remove_reference<remove_cv<_Ty>::type::output_type>::type>::type,std::allocator<remove_cv<remove_reference<remove_cv<_Ty>::type::output_type>::type>::type>>': no appropriate default constructor available
1>        with
1>        [
1>            _Ty=remove_reference<unknown-type>::type
1>        ]
1>c:\users\tomek\source\repos\consoleapplication7\consoleapplication7\ranges.hpp(1476): note: see declaration of 'std::vector<remove_cv<remove_reference<remove_cv<_Ty>::type::output_type>::type>::type,std::allocator<remove_cv<remove_reference<remove_cv<_Ty>::type::output_type>::type>::type>>'
1>        with
1>        [
1>            _Ty=remove_reference<unknown-type>::type
1>        ]
1>c:\users\tomek\source\repos\consoleapplication7\consoleapplication7\ranges.hpp(1477): fatal error C1903: unable to recover from previous error(s); stopping compilation

First doesn't work after sort

As in the title, code below doesn't compile without calling to_vector() after sort

    std::vector<int> vec { 1, 2, 3, 4, 5 };

    auto firstItem = vec
        | rx::sort()
        | rx::first();

transform is called twice on transform+filter

Hi!

Here dead simple example code:

#include <stdio.h>
#include <vector>
#include <rx/ranges.hpp>
int main()
{
  using namespace std;
  using namespace rx;
  vector<int> v = {1,2,3,4,5,6};
  auto r = v | rx::transform([](auto i){printf("tr=%d\n", i);return i*2;}) | filter([](auto i){return i>6;});
  for(auto i : r) {
    printf("for=%d\n", i);
  }
}

I noticed that once filter condition is true, tr= is printed twice for each for= output. IMO it's not really expected behaviour and looks like overhead.

RFE: string extension - split, strip, join

Hello.

I have some preliminary implementation split range, strip transform and join sink. But I'm not sure if they should be part of main lib or should be placed in a separate file as an optional extension.

strip takes two const iterators of input, two const iterators of separator and produces basic_string_view as output.
strip takes range of const CharT*, basic_string_view or basic_string as input and produces basic_string_view as output.
join takes range of const CharT*, basic_string_view or basic_string and const CharT*, basic_string_view or basic_string as input and produces basic_string as output.

Need to discuss this and I'll make corresponding PR.

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.