c++17

Transformations igrnores sf::Sprite's origin

有些话、适合烂在心里 提交于 2021-02-10 05:12:45
问题 Transforming a sprite in SFML, does not regard it's new origin. In my case sf::Sprite is rotating around the axis that is in the left top corner ({0,0}) regardless its origin. Setting new origin with .setOrigin() earlier takes no effect. I am sure that sprite is getting the right origin position earlier which is center of rectangle. My code: In each of my Card class constructors I set the origin of my sprite. card_sprite.setOrigin(Card::get_default_single_card_size().x*Game::get_scale()/2

Parallel for loop over range of array indices in C++17

落花浮王杯 提交于 2021-02-09 07:23:25
问题 I need to update a 100M-element array and would like to do it in parallel. std::for_each(std::execution::par, ...) seems great for this, except that the update needs to access elements of other arrays depending on the index that I am updating. A minimal serial working example of the kind of thing I'm trying to parallelize might look like this: for (size_t i = 0; i < 100'000'000; i++) d[i] = combine(d[i], s[2*i], s[2*i+1]); I could of course manually spawn threads, but that is a lot more code

Parallel for loop over range of array indices in C++17

戏子无情 提交于 2021-02-09 07:23:25
问题 I need to update a 100M-element array and would like to do it in parallel. std::for_each(std::execution::par, ...) seems great for this, except that the update needs to access elements of other arrays depending on the index that I am updating. A minimal serial working example of the kind of thing I'm trying to parallelize might look like this: for (size_t i = 0; i < 100'000'000; i++) d[i] = combine(d[i], s[2*i], s[2*i+1]); I could of course manually spawn threads, but that is a lot more code

std::bind with variadic template and auto return type

孤街醉人 提交于 2021-02-08 18:55:44
问题 Following the code in this question, I have a std::bind with a variadic template function. If I try to provide a function template with auto return, gcc rejects the program: #include <functional> template <typename... Args auto inv_impl(Args... a) { return (a + ...); } template <typename... Args> auto inv(Args... args) { auto bound = std::bind(&inv_impl<Args...>, args...); return bound; } int main() { auto b = inv(1, 2); } The compile error is: foo.cc: In instantiation of ‘auto inv(Args ...)

std::bind with variadic template and auto return type

☆樱花仙子☆ 提交于 2021-02-08 18:49:16
问题 Following the code in this question, I have a std::bind with a variadic template function. If I try to provide a function template with auto return, gcc rejects the program: #include <functional> template <typename... Args auto inv_impl(Args... a) { return (a + ...); } template <typename... Args> auto inv(Args... args) { auto bound = std::bind(&inv_impl<Args...>, args...); return bound; } int main() { auto b = inv(1, 2); } The compile error is: foo.cc: In instantiation of ‘auto inv(Args ...)

std::bind with variadic template and auto return type

扶醉桌前 提交于 2021-02-08 18:49:14
问题 Following the code in this question, I have a std::bind with a variadic template function. If I try to provide a function template with auto return, gcc rejects the program: #include <functional> template <typename... Args auto inv_impl(Args... a) { return (a + ...); } template <typename... Args> auto inv(Args... args) { auto bound = std::bind(&inv_impl<Args...>, args...); return bound; } int main() { auto b = inv(1, 2); } The compile error is: foo.cc: In instantiation of ‘auto inv(Args ...)

std::bind with variadic template and auto return type

旧时模样 提交于 2021-02-08 18:47:43
问题 Following the code in this question, I have a std::bind with a variadic template function. If I try to provide a function template with auto return, gcc rejects the program: #include <functional> template <typename... Args auto inv_impl(Args... a) { return (a + ...); } template <typename... Args> auto inv(Args... args) { auto bound = std::bind(&inv_impl<Args...>, args...); return bound; } int main() { auto b = inv(1, 2); } The compile error is: foo.cc: In instantiation of ‘auto inv(Args ...)

std::bind with variadic template and auto return type

你说的曾经没有我的故事 提交于 2021-02-08 18:40:19
问题 Following the code in this question, I have a std::bind with a variadic template function. If I try to provide a function template with auto return, gcc rejects the program: #include <functional> template <typename... Args auto inv_impl(Args... a) { return (a + ...); } template <typename... Args> auto inv(Args... args) { auto bound = std::bind(&inv_impl<Args...>, args...); return bound; } int main() { auto b = inv(1, 2); } The compile error is: foo.cc: In instantiation of ‘auto inv(Args ...)

std::bind with variadic template and auto return type

久未见 提交于 2021-02-08 18:37:58
问题 Following the code in this question, I have a std::bind with a variadic template function. If I try to provide a function template with auto return, gcc rejects the program: #include <functional> template <typename... Args auto inv_impl(Args... a) { return (a + ...); } template <typename... Args> auto inv(Args... args) { auto bound = std::bind(&inv_impl<Args...>, args...); return bound; } int main() { auto b = inv(1, 2); } The compile error is: foo.cc: In instantiation of ‘auto inv(Args ...)

std::bind with variadic template and auto return type

痞子三分冷 提交于 2021-02-08 18:36:52
问题 Following the code in this question, I have a std::bind with a variadic template function. If I try to provide a function template with auto return, gcc rejects the program: #include <functional> template <typename... Args auto inv_impl(Args... a) { return (a + ...); } template <typename... Args> auto inv(Args... args) { auto bound = std::bind(&inv_impl<Args...>, args...); return bound; } int main() { auto b = inv(1, 2); } The compile error is: foo.cc: In instantiation of ‘auto inv(Args ...)