5 added 1 characters in body
source | link

LINQ-to-objects is already supported in the Standard library and has been since it's inception. The syntax is just a bit different- it was never intended to emulate SQL and has way too many iterators in it. You can make it more reminiscent without too big a hassle.

Edit: When actually attempingattempting to make it more reminiscent without too big a hassle, I determined that it actually could be a significant hassle. It is, however, still completely possible.

LINQ-to-objects is already supported in the Standard library and has been since it's inception. The syntax is just a bit different- it was never intended to emulate SQL and has way too many iterators in it. You can make it more reminiscent without too big a hassle.

Edit: When actually attemping to make it more reminiscent without too big a hassle, I determined that it actually could be a significant hassle. It is, however, still completely possible.

LINQ-to-objects is already supported in the Standard library and has been since it's inception. The syntax is just a bit different- it was never intended to emulate SQL and has way too many iterators in it. You can make it more reminiscent without too big a hassle.

Edit: When actually attempting to make it more reminiscent without too big a hassle, I determined that it actually could be a significant hassle. It is, however, still completely possible.

4 added 428 characters in body
source | link

LINQ-to-objects is already supported in the Standard library and has been since it's inception. The syntax is just a bit different- it was never intended to emulate SQL and has way too many iterators in it. You can make it more reminiscent without too big a hassle.

template<typename T, typename F> class proxy {
    T&& t;
    F&& f;
public:
    template<typename TRef, typename FRef> proxy(TRef&& tref, FRef&& fref) {
        : t(std::forward<TRef>(tref)), f(std::forward<FRef>(fref)) {}
    template<typename ret> operator ret() {
        ret retval;
        std::for_each(t.begin(), t.end(), [&](decltype(*t.begin()) ref) {
            retval.emplace_back(f(ref));
        });
        return retval;
    }
};

template<typename T, typename F> auto Select(T&& t, F&& f) -> proxy<T, F> {
    return proxy<T, F>(t, f);
}

Lazy evaluation? Check- can convert into any container you want. Generic? Check. Easy syntax? Check. The only thingEdit: When actually attemping to make it more reminiscent without too big a hassle, I determined that it actually could make this easier is extension methodsbe a significant hassle. Except I probably screwed up the rvalue references thereIt is, however, still completely possible.

LINQ-to-objects is already supported in the Standard library and has been since it's inception. The syntax is just a bit different- it was never intended to emulate SQL and has way too many iterators in it. You can make it more reminiscent without too big a hassle.

template<typename T, typename F> class proxy {
    T&& t;
    F&& f;
public:
    template<typename TRef, typename FRef> proxy(TRef&& tref, FRef&& fref) {
        : t(std::forward<TRef>(tref)), f(std::forward<FRef>(fref)) {}
    template<typename ret> operator ret() {
        ret retval;
        std::for_each(t.begin(), t.end(), [&](decltype(*t.begin()) ref) {
            retval.emplace_back(f(ref));
        });
        return retval;
    }
};

template<typename T, typename F> auto Select(T&& t, F&& f) -> proxy<T, F> {
    return proxy<T, F>(t, f);
}

Lazy evaluation? Check- can convert into any container you want. Generic? Check. Easy syntax? Check. The only thing that could make this easier is extension methods. Except I probably screwed up the rvalue references there.

LINQ-to-objects is already supported in the Standard library and has been since it's inception. The syntax is just a bit different- it was never intended to emulate SQL and has way too many iterators in it. You can make it more reminiscent without too big a hassle.

Edit: When actually attemping to make it more reminiscent without too big a hassle, I determined that it actually could be a significant hassle. It is, however, still completely possible.

3 added 1 characters in body
source | link

LINQ-to-objects is already supported in the Standard library and has been since it's inception. The syntax is just a bit different- it was never intended to emulate SQL and has way too many iterators in it. You can make it more reminiscent without too big a hassle.

template<typename T, typename F> class proxy {
    T&& t;
    F&& f;
public:
    template<typename TRef, typename FRef> proxy(TRef&& tref, FRef&& fref) {
        : t(std::forward<TRef>(tref)), f(std::forward<FRef>(fref)) {}
    template<typename ret> operator ret() {
        ret retval;
        std::for_each(t.begin(), t.end(), [&](decltype(*t.begin()) ref) {
            retval.emplace_back(f(ref));
        });
        return retval;
    }
};

template<typename T, typename F> auto Select(T&& t, F&& f) -> proxy<T, F> {
    return proxy<T, F>(t, f);
}

Lazy evaluation? Check- can convert into any container you want. Generic? Check. Easy syntax? Check. The only thing that could make this easier is extension methods. Except I probably screwed up the rvalue references there.

LINQ-to-objects is already supported in the Standard library and has been since it's inception. The syntax is just a bit different- it was never intended to emulate SQL and has way too many iterators in it. You can make it more reminiscent without too big a hassle.

template<typename T, typename F> class proxy {
    T&& t;
    F&& f;
public:
    template<typename TRef, typename FRef> proxy(TRef&& tref, FRef&& fref) {
        : t(std::forward<TRef>(tref)), f(std::forward<FRef>(fref)) {}
    template<typename ret> operator ret() {
        ret retval;
        std::for_each(t.begin(), t.end(), [&](decltype(*t.begin()) ref) {
            retval.emplace_back(f(ref));
        });
        return retval;
    }
}

template<typename T, typename F> auto Select(T&& t, F&& f) -> proxy<T, F> {
    return proxy<T, F>(t, f);
}

Lazy evaluation? Check- can convert into any container you want. Generic? Check. Easy syntax? Check. The only thing that could make this easier is extension methods. Except I probably screwed up the rvalue references there.

LINQ-to-objects is already supported in the Standard library and has been since it's inception. The syntax is just a bit different- it was never intended to emulate SQL and has way too many iterators in it. You can make it more reminiscent without too big a hassle.

template<typename T, typename F> class proxy {
    T&& t;
    F&& f;
public:
    template<typename TRef, typename FRef> proxy(TRef&& tref, FRef&& fref) {
        : t(std::forward<TRef>(tref)), f(std::forward<FRef>(fref)) {}
    template<typename ret> operator ret() {
        ret retval;
        std::for_each(t.begin(), t.end(), [&](decltype(*t.begin()) ref) {
            retval.emplace_back(f(ref));
        });
        return retval;
    }
};

template<typename T, typename F> auto Select(T&& t, F&& f) -> proxy<T, F> {
    return proxy<T, F>(t, f);
}

Lazy evaluation? Check- can convert into any container you want. Generic? Check. Easy syntax? Check. The only thing that could make this easier is extension methods. Except I probably screwed up the rvalue references there.

2 added 37 characters in body
source | link
1
source | link