Clang compilation fixes

This commit is contained in:
Nikita Lisitsa 2022-06-11 13:58:54 +03:00
parent ef5b8479ea
commit 9edf94be0c
9 changed files with 27 additions and 17 deletions

View file

@ -17,7 +17,8 @@
#include <cstddef> #include <cstddef>
#include <type_traits> #include <type_traits>
#include <vector> #include <cmath>
#include <unordered_map>
namespace psemek::gfx namespace psemek::gfx
{ {

View file

@ -293,7 +293,7 @@ namespace psemek::gfx
throw std::runtime_error("Number of transforms in a pose must be equal to the number of bones"); throw std::runtime_error("Number of transforms in a pose must be equal to the number of bones");
auto pose_ptr = s.read_ptr<bone_transform<float>>(pose_count); auto pose_ptr = s.read_ptr<bone_transform<float>>(pose_count);
std::string_view name(name_ptr, name_ptr + name_length); std::string_view name(name_ptr, name_length);
result.poses[name] = {pose_ptr, pose_ptr + pose_count}; result.poses[name] = {pose_ptr, pose_ptr + pose_count};
}; };

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <cmath> #include <cmath>
#include <algorithm>
#include <exception> #include <exception>
namespace psemek::ml namespace psemek::ml

View file

@ -21,8 +21,8 @@ namespace psemek::ui
void update(float dt) override; void update(float dt) override;
void set_enabled(bool value); void set_enabled(bool value) override;
void set_hidden(bool value); void set_hidden(bool value) override;
using on_click_callback = std::function<void()>; using on_click_callback = std::function<void()>;

View file

@ -2,6 +2,8 @@
#include <psemek/ui/font.hpp> #include <psemek/ui/font.hpp>
#include <unordered_map>
namespace psemek::ui namespace psemek::ui
{ {

View file

@ -24,9 +24,9 @@ namespace psemek::ui
virtual bool horizontal_scroll() const { return horizontal_; } virtual bool horizontal_scroll() const { return horizontal_; }
virtual bool vertical_scroll() const { return vertical_; } virtual bool vertical_scroll() const { return vertical_; }
virtual bool on_event(mouse_move const & e); virtual bool on_event(mouse_move const & e) override;
virtual bool on_event(mouse_click const & e); virtual bool on_event(mouse_click const & e) override;
virtual bool on_event(mouse_wheel const & e); virtual bool on_event(mouse_wheel const & e) override;
struct shape const & shape() const override { return shape_; } struct shape const & shape() const override { return shape_; }
void reshape(geom::box<float, 2> const & bbox) override; void reshape(geom::box<float, 2> const & bbox) override;

View file

@ -28,6 +28,8 @@ namespace psemek::util
: value{((1 << static_cast<underlying_type>(flags)) | ...)} : value{((1 << static_cast<underlying_type>(flags)) | ...)}
{} {}
flag_set & operator = (flag_set const &) = default;
bool is_set(Flag const & flag) const bool is_set(Flag const & flag) const
{ {
return value & (1 << static_cast<underlying_type>(flag)); return value & (1 << static_cast<underlying_type>(flag));

View file

@ -4,6 +4,7 @@
#include <psemek/util/unused.hpp> #include <psemek/util/unused.hpp>
#include <memory> #include <memory>
#include <array>
using namespace psemek::util; using namespace psemek::util;

View file

@ -4,6 +4,19 @@
#include <chrono> #include <chrono>
#include <vector> #include <vector>
#include <optional> #include <optional>
#include <iostream>
// Have to put it before including to_string.hpp due to how unqualified lookup works,
// see e.g. https://alexanderlobov.net/posts/2019-07-08-function-lookup-in-templates
template <typename T>
std::ostream & operator << (std::ostream & s, std::optional<T> const & o)
{
if (o)
s << *o;
else
s << "(empty)";
return s;
}
#include <psemek/util/to_string.hpp> #include <psemek/util/to_string.hpp>
@ -77,16 +90,6 @@ namespace psemek::test
} }
template <typename T>
std::ostream & operator << (std::ostream & s, std::optional<T> const & o)
{
if (o)
s << *o;
else
s << "(empty)";
return s;
}
#define test_case(name) \ #define test_case(name) \
void name ## _test_case (::psemek::test::context &); \ 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; }(); \ static const auto name ## _test_case_registrator = []{ ::psemek::test::add_test_case(#name, &(name ## _test_case)); return 0; }(); \