Coder Social home page Coder Social logo

combinations_cpp's People

Contributors

artem-ogre avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

combinations_cpp's Issues

Bug in `size()`

In the method size() I think there is a bug. I was not able to compile any code using size().

I believe that the size of the vector needs to be referenced somewhere there instead of directly using std::multiplies.

To reproduce:

#include "combinations.hpp"
#include <iostream>
int main()
{
    std::vector<std::vector<double> > x(4, std::vector<double>(4, 42.0));
    auto ft = make_combinations(x);
    std::cout << ft.size() << std::endl;
    return 0;
}

Expected output: 256

Compilation error:

/usr/include/c++/5/bits/stl_numeric.h: In instantiation of ‘_Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::vector, std::vector<std::vector > >; _Tp = int; _BinaryOperation = std::multiplies]’:
combinations.hpp:177:52: required from ‘combinations::size_type combinations::size() const [with SetsIter = __gnu_cxx::__normal_iterator<const std::vector
, std::vector<std::vector > >; combinations::size_type = long unsigned int]’
text.cpp:14:26: required from here
/usr/include/c++/5/bits/stl_numeric.h:154:22: error: no match for call to ‘(std::multiplies) (int&, const std::vector&)’
__init = __binary_op(__init, *__first);
^
In file included from /usr/include/c++/5/string:48:0,
from /usr/include/c++/5/bits/locale_classes.h:40,
from /usr/include/c++/5/bits/ios_base.h:41,
from /usr/include/c++/5/ios:42,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iterator:64,
from combinations.hpp:25,
from text.cpp:1:
/usr/include/c++/5/bits/stl_function.h:191:7: note: candidate: _Tp std::multiplies<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = long unsigned int]
operator()(const _Tp& __x, const _Tp& __y) const
^
/usr/include/c++/5/bits/stl_function.h:191:7: note: no known conversion for argument 2 from ‘const std::vector’ to ‘const long unsigned int&’

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.