Clang compilation fixes
This commit is contained in:
parent
2c1d486068
commit
e7cac4a618
13 changed files with 41 additions and 41 deletions
|
|
@ -425,7 +425,7 @@ struct controller
|
|||
static constexpr std::size_t inputs = 24 * 7;
|
||||
static constexpr std::size_t outputs = 23;
|
||||
|
||||
static constexpr std::size_t layer1 = outputs;
|
||||
// static constexpr std::size_t layer1 = outputs;
|
||||
// static constexpr std::size_t layer2 = 4;
|
||||
// static constexpr std::size_t layer3 = outputs;
|
||||
|
||||
|
|
@ -529,8 +529,6 @@ void controller::from_eigen(Eigen::VectorXf const & v)
|
|||
template <typename RNG>
|
||||
void controller::mutate(RNG && rng, float amplitude)
|
||||
{
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
random::normal_distribution<float> d{};
|
||||
|
||||
auto visit_m = [&rng, &d, amplitude](auto & m)
|
||||
|
|
@ -558,7 +556,6 @@ void controller::mutate(RNG && rng, float amplitude)
|
|||
visit_v(t1);
|
||||
// visit_v(t2);
|
||||
// visit_v(t3);
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
void controller::reset()
|
||||
|
|
@ -1448,7 +1445,7 @@ void animation_2d_app::do_test()
|
|||
}
|
||||
else
|
||||
{
|
||||
physics.advance(frame_clock.restart().count(), sel, [this](system const & physics){
|
||||
physics.advance(frame_clock.restart().count(), sel, [](system const & physics){
|
||||
return std::vector<float>(physics.joints.size(), 0.f);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -261,6 +261,7 @@ struct node
|
|||
|
||||
virtual bool draw(int level) = 0;
|
||||
virtual node * child(int id) = 0;
|
||||
virtual ~node() {}
|
||||
};
|
||||
|
||||
struct node_controller
|
||||
|
|
@ -389,7 +390,7 @@ bool node_controller::node_impl::draw(int level)
|
|||
|
||||
if (!height_data_future.ready()) return false;
|
||||
|
||||
auto height_data = std::move(height_data_future.get());
|
||||
auto height_data = height_data_future.get();
|
||||
|
||||
for (auto h : height_data)
|
||||
height_range |= exaggeration * static_cast<float>(h);
|
||||
|
|
@ -402,7 +403,7 @@ bool node_controller::node_impl::draw(int level)
|
|||
array.bind();
|
||||
std::size_t offset = controller->index_counts_[level];
|
||||
std::size_t count = controller->index_counts_[level + 1] - offset;
|
||||
gl::DrawElements(gl::TRIANGLE_STRIP, count, gl::UNSIGNED_SHORT, (std::uint16_t const *)(nullptr) + offset);
|
||||
gl::DrawElements(gl::TRIANGLE_STRIP, count, gl::UNSIGNED_SHORT, reinterpret_cast<void const *>(offset * sizeof(std::uint16_t)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ void water_2d_app::update()
|
|||
return std::pair{N - p.second, p.first - p.second};
|
||||
};
|
||||
|
||||
auto const rot2 = [this, rot1](std::pair<int, int> const & p)
|
||||
auto const rot2 = [rot1](std::pair<int, int> const & p)
|
||||
{
|
||||
return rot1(rot1(p));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ namespace psemek::audio
|
|||
, spec(spec)
|
||||
{}
|
||||
|
||||
void volume(float value)
|
||||
void volume(float value) override
|
||||
{
|
||||
int v = std::min(128, std::max(0, static_cast<int>(std::round(value * MIX_MAX_VOLUME))));
|
||||
Mix_Volume(channel, v);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace psemek::geom
|
|||
template <typename T, std::size_t N>
|
||||
struct box
|
||||
{
|
||||
detail::array<interval<T>, N>::type axes;
|
||||
typename detail::array<interval<T>, N>::type axes;
|
||||
|
||||
using point_type = point<T, N>;
|
||||
using vector_type = vector<T, N>;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace psemek::geom
|
|||
static constexpr std::size_t static_rows = R;
|
||||
static constexpr std::size_t static_columns = C;
|
||||
|
||||
detail::array<T, R * C>::type coords;
|
||||
typename detail::array<T, R * C>::type coords;
|
||||
|
||||
std::size_t rows() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace psemek::geom
|
|||
using scalar_type = T;
|
||||
static constexpr std::size_t static_dimension = N;
|
||||
|
||||
detail::array<T, N>::type coords;
|
||||
typename detail::array<T, N>::type coords;
|
||||
|
||||
point() = default;
|
||||
point(point const &) = default;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace psemek::geom
|
|||
using scalar_type = T;
|
||||
static constexpr std::size_t static_dimension = N;
|
||||
|
||||
detail::array<T, N>::type coords;
|
||||
typename detail::array<T, N>::type coords;
|
||||
|
||||
vector() = default;
|
||||
vector(vector const &) = default;
|
||||
|
|
|
|||
|
|
@ -492,6 +492,7 @@ namespace psemek::gfx
|
|||
// Guard against unsigned char
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wtype-limits"
|
||||
#pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare"
|
||||
if ((c < 32) || (c >= 128)) c = '?';
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace psemek::random
|
|||
// see https://en.cppreference.com/w/cpp/numeric/random/generate_canonical
|
||||
|
||||
static constexpr std::size_t digits = std::numeric_limits<T>::digits;
|
||||
static constexpr T const limit = std::pow<T>(2, digits);
|
||||
static T const limit = std::pow<T>(2, digits);
|
||||
|
||||
T const R = static_cast<T>(rng.max()) - static_cast<T>(rng.min()) + 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -223,12 +223,12 @@ namespace psemek::util
|
|||
template <typename Handle, typename ... Types>
|
||||
void heterogeneous_container<Handle, Types...>::erase(handle h)
|
||||
{
|
||||
auto [i, hh] = unpack_handle(h);
|
||||
if (i >= types_count)
|
||||
auto u = unpack_handle(h);
|
||||
if (u.first >= types_count)
|
||||
throw bad_handle{};
|
||||
detail::tuple_apply_at([hh](auto & t) -> void {
|
||||
t.erase(hh);
|
||||
}, storage_, i);
|
||||
detail::tuple_apply_at([&u](auto & t) -> void {
|
||||
t.erase(u.second);
|
||||
}, storage_, u.first);
|
||||
}
|
||||
|
||||
template <typename Handle, typename ... Types>
|
||||
|
|
@ -240,12 +240,12 @@ namespace psemek::util
|
|||
}
|
||||
|
||||
template <typename Handle, typename ... Types>
|
||||
heterogeneous_container<Handle, Types...>::any heterogeneous_container<Handle, Types...>::get(handle h) const
|
||||
typename heterogeneous_container<Handle, Types...>::any heterogeneous_container<Handle, Types...>::get(handle h) const
|
||||
{
|
||||
auto [i, hh] = unpack_handle(h);
|
||||
return detail::tuple_apply_at([hh](auto & t) -> any {
|
||||
return t[hh];
|
||||
}, storage_, i);
|
||||
auto u = unpack_handle(h);
|
||||
return detail::tuple_apply_at([&u](auto & t) -> any {
|
||||
return t[u.second];
|
||||
}, storage_, u.first);
|
||||
}
|
||||
|
||||
template <typename Handle, typename ... Types>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <psemek/test/test.hpp>
|
||||
|
||||
#include <psemek/util/function.hpp>
|
||||
#include <psemek/util/unused.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
|
@ -23,7 +24,7 @@ static void util_function_assign_test(bool light)
|
|||
if (light)
|
||||
f = [&counter]{ ++counter; };
|
||||
else
|
||||
f = [&counter, h = heavy{}]{ ++counter; };
|
||||
f = [&counter, h = heavy{}]{ unused(h); ++counter; };
|
||||
expect(f);
|
||||
|
||||
expect_equal(counter, 0);
|
||||
|
|
@ -42,7 +43,7 @@ static void util_function_move_test(bool light)
|
|||
if (light)
|
||||
f = [&counter]{ ++counter; };
|
||||
else
|
||||
f = [&counter, h = heavy{}]{ ++counter; };
|
||||
f = [&counter, h = heavy{}]{ unused(h); ++counter; };
|
||||
expect(f);
|
||||
|
||||
function<void()> g;
|
||||
|
|
@ -88,8 +89,8 @@ static void util_function_destroy_test(bool light)
|
|||
}
|
||||
else
|
||||
{
|
||||
f = [p, h = heavy{}]{ ++*p; };
|
||||
g = [p, h = heavy{}]{ --*p; };
|
||||
f = [p, h = heavy{}]{ unused(h); ++*p; };
|
||||
g = [p, h = heavy{}]{ unused(h); --*p; };
|
||||
}
|
||||
expect(f);
|
||||
expect(g);
|
||||
|
|
|
|||
|
|
@ -82,27 +82,27 @@ void name ## _test_case (::psemek::test::context &); \
|
|||
static const auto name ## _test_case_registrator = []{ ::psemek::test::add_test_case(#name, &(name ## _test_case)); return 0; }(); \
|
||||
void name ## _test_case ([[maybe_unused]] ::psemek::test::context & _ctx)
|
||||
|
||||
#define fail(...) throw ::psemek::test::failure(::psemek::util::to_string(__VA_ARGS__), ::psemek::util::to_string(__FILE__, ":", __LINE__))
|
||||
#define psemek_test_fail(...) throw ::psemek::test::failure(::psemek::util::to_string(__VA_ARGS__), ::psemek::util::to_string(__FILE__, ":", __LINE__))
|
||||
|
||||
#define expect(cond) if (!static_cast<bool>(cond)) fail("!(" #cond ")")
|
||||
#define expect(cond) if (!static_cast<bool>(cond)) psemek_test_fail("!(" #cond ")")
|
||||
|
||||
#define expect_equal(expr1, expr2) if ((expr1) != (expr2)) fail(#expr1, " (", (expr1), ") != ", #expr2, " (", (expr2), ")")
|
||||
#define expect_equal(expr1, expr2) if ((expr1) != (expr2)) psemek_test_fail(#expr1, " (", (expr1), ") != ", #expr2, " (", (expr2), ")")
|
||||
|
||||
#define expect_equal_ptr(expr1, expr2) if ((expr1) != (expr2)) fail(#expr1, " (", (void*)(expr1), ") != ", #expr2, " (", (void*)(expr2), ")")
|
||||
#define expect_equal_ptr(expr1, expr2) if ((expr1) != (expr2)) psemek_test_fail(#expr1, " (", (void*)(expr1), ") != ", #expr2, " (", (void*)(expr2), ")")
|
||||
|
||||
#define expect_different(expr1, expr2) if ((expr1) == (expr2)) fail(#expr1, " (", (expr1), ") == ", #expr2, " (", (expr2), ")")
|
||||
#define expect_different(expr1, expr2) if ((expr1) == (expr2)) psemek_test_fail(#expr1, " (", (expr1), ") == ", #expr2, " (", (expr2), ")")
|
||||
|
||||
#define expect_different_ptr(expr1, expr2) if ((expr1) == (expr2)) fail(#expr1, " (", (void*)(expr1), ") == ", #expr2, " (", (void*)(expr2), ")")
|
||||
#define expect_different_ptr(expr1, expr2) if ((expr1) == (expr2)) psemek_test_fail(#expr1, " (", (void*)(expr1), ") == ", #expr2, " (", (void*)(expr2), ")")
|
||||
|
||||
#define expect_less(expr1, expr2) if ((expr1) >= (expr2)) fail(#expr1, " (", (expr1), ") >= ", #expr2, " (", (expr2), ")")
|
||||
#define expect_lequal(expr1, expr2) if ((expr2) > (expr2)) fail(#expr1, " (", (expr1), ") > ", #expr2, " (", (expr2), ")")
|
||||
#define expect_greater(expr1, expr2) if ((expr1) <= (expr2)) fail(#expr1, " (", (expr1), ") <= ", #expr2, " (", (expr2), ")")
|
||||
#define expect_gequal(expr1, expr2) if ((expr1) < (expr2)) fail(#expr1, " (", (expr1), ") < ", #expr2, " (", (expr2), ")")
|
||||
#define expect_less(expr1, expr2) if ((expr1) >= (expr2)) psemek_test_fail(#expr1, " (", (expr1), ") >= ", #expr2, " (", (expr2), ")")
|
||||
#define expect_lequal(expr1, expr2) if ((expr2) > (expr2)) psemek_test_fail(#expr1, " (", (expr1), ") > ", #expr2, " (", (expr2), ")")
|
||||
#define expect_greater(expr1, expr2) if ((expr1) <= (expr2)) psemek_test_fail(#expr1, " (", (expr1), ") <= ", #expr2, " (", (expr2), ")")
|
||||
#define expect_gequal(expr1, expr2) if ((expr1) < (expr2)) psemek_test_fail(#expr1, " (", (expr1), ") < ", #expr2, " (", (expr2), ")")
|
||||
|
||||
#define expect_small(expr1, expr2) if (std::abs((expr1)) > (expr2)) fail("abs(", #expr1, ") (", std::abs((expr1)), ") >= ", #expr2, " (", (expr2), ")")
|
||||
#define expect_close(expr1, expr2, expr3) if (std::abs((expr1) - (expr2)) > (expr3)) fail("abs(", #expr1, " - ", #expr2, ") (", std::abs((expr1) - (expr2)), ") >= ", #expr3, " (", (expr3), ")")
|
||||
#define expect_small(expr1, expr2) if (std::abs((expr1)) > (expr2)) psemek_test_fail("abs(", #expr1, ") (", std::abs((expr1)), ") >= ", #expr2, " (", (expr2), ")")
|
||||
#define expect_close(expr1, expr2, expr3) if (std::abs((expr1) - (expr2)) > (expr3)) psemek_test_fail("abs(", #expr1, " - ", #expr2, ") (", std::abs((expr1) - (expr2)), ") >= ", #expr3, " (", (expr3), ")")
|
||||
|
||||
#define expect_throw(expr, type) do { bool thrown = false; try { (void)(expr); } catch (type const &) { thrown = true; } if (!thrown) fail(#expr, " didn't throw ", #type); } while (false)
|
||||
#define expect_throw(expr, type) do { bool thrown = false; try { (void)(expr); } catch (type const &) { thrown = true; } if (!thrown) psemek_test_fail(#expr, " didn't throw ", #type); } while (false)
|
||||
|
||||
#define test_profile(name) \
|
||||
if (::psemek::test::profiler name ## _profiler(#name, _ctx); true)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue