ryanhaining / cppitertools

Implementation of python itertools and builtin iteration functions for C++17
https://twitter.com/cppitertools
BSD 2-Clause "Simplified" License
1.37k stars 115 forks source link

compilation of test code on OSX #20

Closed jkhoogland closed 9 years ago

jkhoogland commented 9 years ago

Hi, I tried to build the test code on OSX, but a lot of the builds, which include functional.h fail with the error below. I have not found a way to fix this yet, but if you have any suggestions where to start it would be appreciated. Regards Jiri

System:
$  uname -a
Darwin JiriMBP.home 14.4.0 Darwin Kernel Version 14.4.0: Thu May 28 11:35:04 PDT 2015; root:xnu-2782.30.5~1/RELEASE_X86_64 x86_64 i386 MacBookPro11,2 Darwin
$  g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.4.0
Thread model: posix
c++ -o test_combinations.o -c -g -Wall -Wextra -std=c++11 -fdiagnostics-color=always -I/usr/local/include -I. -I/Users/Jiri/Documents/lib/cpp/iter/cppitertools test_combinations.cpp
In file included from test_combinations.cpp:1:
In file included from ./helpers.hpp:4:
In file included from /Users/Jiri/Documents/lib/cpp/iter/cppitertools/iterbase.hpp:13:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:477:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1645:31: error: no matching constructor for
      initialization of 'std::__1::vector<char, std::__1::allocator<char> >'
            ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
                              ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1572:18: note: in instantiation of function
      template specialization 'std::__1::allocator<std::__1::vector<char, std::__1::allocator<char> > >::construct<std::__1::vector<char,
      std::__1::allocator<char> >, iter::IteratorIterator<std::__1::__wrap_iter<std::__1::__wrap_iter<char *> *>, long>,
      iter::IteratorIterator<std::__1::__wrap_iter<std::__1::__wrap_iter<char *> *>, long> >' requested here
            {__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
                 ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1453:14: note: in instantiation of function
      template specialization 'std::__1::allocator_traits<std::__1::allocator<std::__1::vector<char, std::__1::allocator<char> > >
      >::__construct<std::__1::vector<char, std::__1::allocator<char> >, iter::IteratorIterator<std::__1::__wrap_iter<std::__1::__wrap_iter<char *> *>, long>,
      iter::IteratorIterator<std::__1::__wrap_iter<std::__1::__wrap_iter<char *> *>, long> >' requested here
            {__construct(__has_construct<allocator_type, pointer, _Args...>(),
             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:1633:25: note: in instantiation of function
      template specialization 'std::__1::allocator_traits<std::__1::allocator<std::__1::vector<char, std::__1::allocator<char> > >
      >::construct<std::__1::vector<char, std::__1::allocator<char> >, iter::IteratorIterator<std::__1::__wrap_iter<std::__1::__wrap_iter<char *> *>, long>,
      iter::IteratorIterator<std::__1::__wrap_iter<std::__1::__wrap_iter<char *> *>, long> >' requested here
        __alloc_traits::construct(this->__alloc(),
                        ^
test_combinations.cpp:21:12: note: in instantiation of function template specialization 'std::__1::vector<std::__1::vector<char, std::__1::allocator<char> >,
      std::__1::allocator<std::__1::vector<char, std::__1::allocator<char> > >
      >::emplace_back<iter::IteratorIterator<std::__1::__wrap_iter<std::__1::__wrap_iter<char *> *>, long>,
      iter::IteratorIterator<std::__1::__wrap_iter<std::__1::__wrap_iter<char *> *>, long> >' requested here
        sc.emplace_back(std::begin(v), std::end(v));
           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:521:5: note: candidate constructor not viable:
      no known conversion from 'iter::IteratorIterator<std::__1::__wrap_iter<std::__1::__wrap_iter<char *> *>, long>' to 'size_type' (aka 'unsigned long') for
      1st argument
    vector(size_type __n, const_reference __x);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:555:5: note: candidate constructor not viable:
      no known conversion from 'iter::IteratorIterator<std::__1::__wrap_iter<std::__1::__wrap_iter<char *> *>, long>' to 'initializer_list<value_type>' for 1st
      argument
    vector(initializer_list<value_type> __il, const allocator_type& __a);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:566:5: note: candidate constructor not viable:
      no known conversion from 'iter::IteratorIterator<std::__1::__wrap_iter<std::__1::__wrap_iter<char *> *>, long>' to 'const std::__1::vector<char,
      std::__1::allocator<char> >' for 1st argument
    vector(const vector& __x, const allocator_type& __a);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:574:5: note: candidate constructor not viable:
      no known conversion from 'iter::IteratorIterator<std::__1::__wrap_iter<std::__1::__wrap_iter<char *> *>, long>' to
      'std::__1::vector<char, std::__1::allocator<char> >' for 1st argument
    vector(vector&& __x, const allocator_type& __a);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:525:35: note: candidate template ignored:
      disabled by 'enable_if' [with _InputIterator = iter::IteratorIterator<std::__1::__wrap_iter<std::__1::__wrap_iter<char *> *>, long>]
               typename enable_if<__is_input_iterator  <_InputIterator>::value &&
                                  ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:540:35: note: candidate template ignored:
      disabled by 'enable_if' [with _ForwardIterator = iter::IteratorIterator<std::__1::__wrap_iter<std::__1::__wrap_iter<char *> *>, long>]
               typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
                                  ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:532:9: note: candidate constructor template not
      viable: requires at least 3 arguments, but 2 were provided
        vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
        ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:546:9: note: candidate constructor template not
      viable: requires at least 3 arguments, but 2 were provided
        vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
        ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:510:40: note: candidate constructor not viable:
      requires single argument '__a', but 2 arguments were provided
    _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
                                       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:517:14: note: candidate constructor not viable:
      requires single argument '__n', but 2 arguments were provided
    explicit vector(size_type __n);
             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:553:5: note: candidate constructor not viable:
      requires single argument '__il', but 2 arguments were provided
    vector(initializer_list<value_type> __il);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:565:5: note: candidate constructor not viable:
      requires single argument '__x', but 2 arguments were provided
    vector(const vector& __x);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:571:5: note: candidate constructor not viable:
      requires single argument '__x', but 2 arguments were provided
    vector(vector&& __x)
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:522:5: note: candidate constructor not viable:
      requires 3 arguments, but 2 were provided
    vector(size_type __n, const_reference __x, const allocator_type& __a);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:503:5: note: candidate constructor not viable:
      requires 0 arguments, but 2 were provided
    vector()
    ^
1 error generated.
scons: *** [test_combinations.o] Error 1
scons: building terminated because of errors.
ryanhaining commented 9 years ago

The issue seems to be with libc++ from what I can tell so far. I need to get a more workable environment then what I'm throwing together right now to figure out why. If you add -stdlib=libstdc++ to your flags do you still get this error?

ryanhaining commented 9 years ago

Okay, the problem was in the iteratoriterator implementation where I messed up with iterator_traits. libc++ was doing more verification in the vector constructor's enable_if than libstdc++, so it found the error. It's not specific to Mac. It should all be fine now, but if it's still not working please reopen the issue, I expect the error message will be different at least.

jkhoogland commented 9 years ago

Many thanks, it is building now... Jiri