Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for iterator type error in example pyramid.cpp #90

Closed
wants to merge 2 commits into from
Closed

Fix for iterator type error in example pyramid.cpp #90

wants to merge 2 commits into from

Conversation

erfansamandarian
Copy link

Pyramid example doesn't work due to mcpp::HeightMap not supporting direct iteration over the heights stored in array.

See below.

rowan@kinson:~/Code/rmit/studio/examples$ mining pyramid_broken
===============================================
MINING: Compiling pyramid_broken.cc into pyramid_broken
===============================================
In file included from pyramid_broken.cc:1:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/algorithm:1751:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/copy.h:15:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/min.h:14:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/min_element.h:55:3: error: static assertion failed due to requirement '__has_iterator_category_convertible_to<mcpp::HeightMap::Iterator, std::forward_iterator_tag, false>::value': std::min_element requires a ForwardIterator
  static_assert(__has_forward_iterator_category<_ForwardIterator>::value,
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/min_element.h:67:19: note: in instantiation of function template specialization 'std::min_element<mcpp::HeightMap::Iterator, std::__less<void, void>>' requested here
    return _VSTD::min_element(__first, __last, __less<>());
                  ^
pyramid_broken.cc:36:28: note: in instantiation of function template specialization 'std::min_element<mcpp::HeightMap::Iterator>' requested here
    int min_height = *std::min_element(heights.begin(), heights.end());
                           ^
1 error generated.
===============================================
MINING: Executing pyramid_broken
===============================================
mining:13: no such file or directory: ./pyramid_broken

Wrote rudimentary fix for the pyramid example, which extracts height values numbers into vector for std::min_element to work.

@erfansamandarian erfansamandarian changed the title Fix for iterator type error Fix for iterator type error in example pyramid.cpp Sep 12, 2024
@erfansamandarian
Copy link
Author

Nevermind, had old build, fixed in #86.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant