Reputeless / PerlinNoise

Header-only Perlin noise library for modern C++ (C++17/C++20)
MIT License
673 stars 77 forks source link

Trouble using this with C++17 source #2

Closed psotos closed 4 years ago

psotos commented 4 years ago

Hi there!

I am getting back into C++, so have that as a caveat. I haven't programmed in it since the 90s. What do I need to do in order to use this code with mine? I am currently getting this error:

Scanning dependencies of target gen2 [ 33%] Building CXX object CMakeFiles/gen2.dir/src/main.cpp.o In file included from /usr/include/c++/7/algorithm:62:0, from /home/psotos/Documents/workspace/gen2/src/main.cpp:4: /usr/include/c++/7/bits/stl_algo.h: In instantiation of ‘void std::shuffle(_RAIter, _RAIter, _UGenerator&&) [with _RAIter = unsigned char*; _UGenerator = int&]’: /home/<myusername>/Documents/workspace/gen2/src/./PerlinNoise/PerlinNoise.hpp:96:16: required from ‘void siv::PerlinNoise::reseed(URNG&) [with URNG = int]’ /home/<myusername>/Documents/workspace/gen2/src/./PerlinNoise/PerlinNoise.hpp:70:4: required from ‘siv::PerlinNoise::PerlinNoise(URNG&) [with URNG = int]’ /home/<myusername>/Documents/workspace/gen2/src/main.cpp:25:36: required from here /usr/include/c++/7/bits/stl_algo.h:3813:2: error: ‘std::remove_reference<int&>::type {aka int}’ is not a class, struct, or union type __uc_type; ^~~~~~~~~ /usr/include/c++/7/bits/stl_algo.h:3841:37: error: ‘std::remove_reference<int&>::type {aka int}’ is not a class, struct, or union type const pair<__uc_type, __uc_type> __pospos = ^~~~~~~~ /usr/include/c++/7/bits/stl_algo.h:3841:37: error: ‘std::remove_reference<int&>::type {aka int}’ is not a class, struct, or union type CMakeFiles/gen2.dir/build.make:62: recipe for target 'CMakeFiles/gen2.dir/src/main.cpp.o' failed

Reputeless commented 4 years ago

Use std::uint32_t instead of int with your seed value. (see below)

Reputeless commented 4 years ago

b6e7293 fixed this issue. PerlinNoise::PerlinNoise(seed) and PerlinNoise::reseed(seed) now accepts any integer type. Thank you for your report.