diff --git a/.clang-tidy b/.clang-tidy index 1df1ea1b..5e863d4b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,9 +5,11 @@ Checks: '-*, -cppcoreguidelines-pro-bounds-constant-array-index, -cppcoreguidelines-pro-type-vararg, -cppcoreguidelines-non-private-member-variables-in-classes, + -cppcoreguidelines-avoid-do-while, llvm-*, -llvm-header-guard, -llvm-include-order, + -llvm-namespace-comment, clang-analyzer-*, modernize-*, -modernize-use-trailing-return-type, @@ -17,6 +19,7 @@ Checks: '-*, -modernize-use-using, performance-*, -performance-noexcept-move-constructor, + -performance-enum-size, portability-*, readability-*, -readability-redundant-member-init, @@ -25,14 +28,21 @@ Checks: '-*, -readability-named-parameter, -readability-redundant-access-specifiers, -readability-magic-numbers, + -readability-braces-around-statements, + -readability-identifier-length, hicpp-*, -hicpp-avoid-c-arrays, -hicpp-uppercase-literal-suffix, -hicpp-noexcept-move, -hicpp-vararg, -hicpp-member-init, + -hicpp-braces-around-statements, + -hicpp-named-parameter, misc-*, -misc-non-private-member-variables-in-classes' +CheckOptions: + - key: AllowPartialMove + value: true # Disabled Options Explanation: # CppCoreGuidelines: diff --git a/cmake/frontend/emscripten.cmake b/cmake/frontend/emscripten.cmake index 8e61c126..c1cd356d 100644 --- a/cmake/frontend/emscripten.cmake +++ b/cmake/frontend/emscripten.cmake @@ -3,7 +3,7 @@ function(nui_prepare_emscripten_target) NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS "NO_INLINE;NO_INLINE_INJECT;LEAN_INDEX_HTML" "TARGET;PREJS;STATIC;UNPACKED_MODE" - "EMSCRIPTEN_LINK_OPTIONS;EMSCRIPTEN_COMPILE_OPTIONS;PARCEL_ARGS;NPM_INSTALL_ARGS" + "EMSCRIPTEN_LINK_OPTIONS;EMSCRIPTEN_COMPILE_OPTIONS;PARCEL_ARGS;NPM_INSTALL_ARGS;OBSERVED_BUNDLE_FILES" ${ARGN} ) @@ -43,7 +43,8 @@ function(nui_prepare_emscripten_target) ) add_custom_command( - OUTPUT "${CMAKE_BINARY_DIR}/bin/index.html" + OUTPUT "${CMAKE_BINARY_DIR}/bin/index.html" + DEPENDS ${NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS_OBSERVED_BUNDLE_FILES} COMMAND ${CMAKE_COMMAND} -E copy_directory "${NUI_SOURCE_DIRECTORY}/nui/js" "${NUI_MODULE_BUILD_DIR}/nui-js" COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_BINARY_DIR}/static" COMMAND ${CMAKE_COMMAND} -E copy_directory ${NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS_STATIC} "${CMAKE_BINARY_DIR}/static" diff --git a/nui/include/nui/backend/rpc_hub.hpp b/nui/include/nui/backend/rpc_hub.hpp index 6fee3bb9..7dc17fbb 100644 --- a/nui/include/nui/backend/rpc_hub.hpp +++ b/nui/include/nui/backend/rpc_hub.hpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -40,7 +39,7 @@ namespace Nui template constexpr static auto wrapFunction(FunctionT&& func) { - return [func = std::move(func)](nlohmann::json const& args) mutable { + return [func = std::forward(func)](nlohmann::json const& args) mutable { func(args); }; } @@ -52,7 +51,7 @@ namespace Nui template constexpr static auto wrapFunction(FunctionT&& func) { - return [func = std::move(func)](nlohmann::json const& args) mutable { + return [func = std::forward(func)](nlohmann::json const& args) mutable { func(extractJsonMember(args[Is])...); }; } @@ -78,7 +77,7 @@ namespace Nui class RpcHub { public: - RpcHub(Window& window); + explicit RpcHub(Window& window); ~RpcHub() = default; RpcHub(const RpcHub&) = delete; RpcHub& operator=(const RpcHub&) = delete; @@ -153,13 +152,15 @@ namespace Nui template void callRemote(std::string const& name, Arg&& arg) const { - nlohmann::json j = arg; - callRemoteImpl(name, std::move(j)); + nlohmann::json json = std::forward(arg); + callRemoteImpl(name, json); } void callRemote(std::string const& name, nlohmann::json const& json) const { callRemoteImpl(name, json); } + // I dont want to remove this overload in case there are some rvalue nlohmanns? + // NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) void callRemote(std::string const& name, nlohmann::json&& json) const { callRemoteImpl(name, json); @@ -238,10 +239,7 @@ namespace Nui }}}) .first->second.get(); } - else - { - return iter->second.get(); - } + return iter->second.get(); } private: diff --git a/nui/include/nui/data_structures/selectables_registry.hpp b/nui/include/nui/data_structures/selectables_registry.hpp index 209478b8..62142b2f 100644 --- a/nui/include/nui/data_structures/selectables_registry.hpp +++ b/nui/include/nui/data_structures/selectables_registry.hpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -66,6 +65,7 @@ namespace Nui ItemWithId(ItemWithId&&) = default; ItemWithId& operator=(ItemWithId const&) = default; ItemWithId& operator=(ItemWithId&&) = default; + ~ItemWithId() = default; /// @brief Compares the id of the item. bool operator<(ItemWithId const& other) const @@ -197,7 +197,7 @@ namespace Nui using IteratorBase::operator=; using IteratorBase::wrappedIterator_; - ConstIterator(typename ItemContainerType::iterator iter) + explicit ConstIterator(typename ItemContainerType::iterator iter) : IteratorBase{std::move(iter)} {} @@ -400,6 +400,9 @@ namespace Nui { ++itemCount_; ++result; + // selected is a set item, and therefore immutable, so we need to const_cast to move it. + // this would break the set, but its cleared afterwards anyway. + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) entry->item = std::move(const_cast(selected).item); } } diff --git a/nui/include/nui/event_system/event.hpp b/nui/include/nui/event_system/event.hpp index 5ab1b8a3..cfdd432e 100644 --- a/nui/include/nui/event_system/event.hpp +++ b/nui/include/nui/event_system/event.hpp @@ -10,7 +10,13 @@ namespace Nui { virtual bool call(std::size_t eventId) = 0; virtual bool valid() const = 0; + virtual ~EventImpl() = default; + EventImpl() = default; + EventImpl(EventImpl const&) = default; + EventImpl(EventImpl&&) = default; + EventImpl& operator=(EventImpl const&) = default; + EventImpl& operator=(EventImpl&&) = default; }; struct TwoFunctorEventImpl : public EventImpl @@ -39,7 +45,7 @@ namespace Nui class Event { public: - Event( + explicit Event( std::function action, std::function valid = [] { @@ -51,8 +57,9 @@ namespace Nui Event(Event&&) = default; Event& operator=(Event const&) = delete; Event& operator=(Event&&) = default; + ~Event() = default; - operator bool() const + explicit operator bool() const { return impl_->valid(); } diff --git a/nui/include/nui/event_system/event_registry.hpp b/nui/include/nui/event_system/event_registry.hpp index 2e36752f..0887a6d7 100644 --- a/nui/include/nui/event_system/event_registry.hpp +++ b/nui/include/nui/event_system/event_registry.hpp @@ -4,9 +4,7 @@ #include #include -#include #include -#include namespace Nui { diff --git a/nui/include/nui/event_system/observed_value.hpp b/nui/include/nui/event_system/observed_value.hpp index faa1244e..17c43d72 100644 --- a/nui/include/nui/event_system/observed_value.hpp +++ b/nui/include/nui/event_system/observed_value.hpp @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include @@ -18,7 +17,8 @@ #include #include #include -#include +#include +#include namespace Nui { @@ -36,26 +36,63 @@ namespace Nui {} virtual ~ObservedBase() = default; ObservedBase(ObservedBase const&) = delete; - ObservedBase(ObservedBase&& other) + ObservedBase(ObservedBase&& other) noexcept : eventContext_{other.eventContext_} , attachedEvents_{} , attachedOneshotEvents_{} { // events are outside the value logic of the observed class. the contained value is moved, but the events // are merged. - for (auto& event : other.attachedEvents_) - attachedEvents_.push_back(std::move(event)); - for (auto& event : other.attachedOneshotEvents_) - attachedOneshotEvents_.push_back(std::move(event)); + try + { + attachedEvents_.reserve(attachedEvents_.size() + other.attachedEvents_.size()); + attachedOneshotEvents_.reserve(attachedOneshotEvents_.size() + other.attachedOneshotEvents_.size()); + + for (auto& event : other.attachedEvents_) + { + // Dont want to lose the move if event becomes non trivial + // NOLINTNEXTLINE(performance-move-const-arg, hicpp-move-const-arg) + attachedEvents_.push_back(std::move(event)); + } + for (auto& event : other.attachedOneshotEvents_) + { + // Dont want to lose the move if event becomes non trivial + // NOLINTNEXTLINE(performance-move-const-arg, hicpp-move-const-arg) + attachedOneshotEvents_.push_back(std::move(event)); + } + } + catch (...) + { + std::terminate(); + } } ObservedBase& operator=(ObservedBase const&) = delete; - ObservedBase& operator=(ObservedBase&& other) + ObservedBase& operator=(ObservedBase&& other) noexcept { eventContext_ = other.eventContext_; - for (auto& event : other.attachedEvents_) - attachedEvents_.push_back(std::move(event)); - for (auto& event : other.attachedOneshotEvents_) - attachedOneshotEvents_.push_back(std::move(event)); + try + { + attachedEvents_.reserve(attachedEvents_.size() + other.attachedEvents_.size()); + attachedOneshotEvents_.reserve(attachedOneshotEvents_.size() + other.attachedOneshotEvents_.size()); + + for (auto& event : other.attachedEvents_) + { + // Dont want to lose the move if event becomes non trivial + // NOLINTNEXTLINE(performance-move-const-arg, hicpp-move-const-arg) + attachedEvents_.push_back(std::move(event)); + } + for (auto& event : other.attachedOneshotEvents_) + { + // Dont want to lose the move if event becomes non trivial + // NOLINTNEXTLINE(performance-move-const-arg, hicpp-move-const-arg) + attachedOneshotEvents_.push_back(std::move(event)); + } + } + catch (...) + { + std::terminate(); + } + return *this; } @@ -103,7 +140,7 @@ namespace Nui for (auto& event : attachedEvents_) { auto activationResult = eventContext_->activateEvent(event); - if (activationResult.found == false) + if (!activationResult.found) event = EventRegistry::invalidEventId; } for (auto& event : attachedOneshotEvents_) @@ -139,22 +176,44 @@ namespace Nui { public: explicit ModificationProxy(ModifiableObserved& observed) - : observed_{observed} + : observed_{&observed} , now_{false} {} explicit ModificationProxy(ModifiableObserved& observed, bool now) - : observed_{observed} + : observed_{&observed} , now_{now} {} + ModificationProxy(ModificationProxy const&) = delete; + ModificationProxy& operator=(ModificationProxy const&) = delete; + ModificationProxy(ModificationProxy&& other) noexcept + : observed_{other.observed_} + , now_{other.now_} + { + other.observed_ = nullptr; + } + ModificationProxy& operator=(ModificationProxy&& other) noexcept + { + if (this != &other) + { + observed_ = other.observed_; + now_ = other.now_; + other.observed_ = nullptr; + } + return *this; + } ~ModificationProxy() { try { + if (observed_ == nullptr) + return; + if (now_) - observed_.updateNow(true); + observed_->updateNow(true); else - observed_.update(true); + observed_->update(true); } + // NOLINTNEXTLINE(bugprone-empty-catch) catch (...) { // TODO: log? @@ -162,23 +221,23 @@ namespace Nui } auto& value() { - return observed_.contained_; + return observed_->contained_; } auto* operator->() { - return &observed_.contained_; + return &observed_->contained_; } auto& operator*() { - return observed_.contained_; + return observed_->contained_; } - operator ContainedT&() + explicit operator ContainedT&() { - return observed_.contained_; + return observed_->contained_; } private: - ModifiableObserved& observed_; + ModifiableObserved* observed_; bool now_; }; @@ -188,14 +247,14 @@ namespace Nui , contained_{} {} ModifiableObserved(const ModifiableObserved&) = delete; - ModifiableObserved(ModifiableObserved&& other) + ModifiableObserved(ModifiableObserved&& other) noexcept : ObservedBase{std::move(other)} , contained_{std::move(other.contained_)} { update(); }; ModifiableObserved& operator=(const ModifiableObserved&) = delete; - ModifiableObserved& operator=(ModifiableObserved&& other) + ModifiableObserved& operator=(ModifiableObserved&& other) noexcept { if (this != &other) { @@ -217,9 +276,10 @@ namespace Nui update(); return *this; } - ~ModifiableObserved() = default; + ~ModifiableObserved() override = default; template + requires std::is_constructible_v explicit ModifiableObserved(T&& t) : ObservedBase{CustomEventContextFlag, &globalEventContext} , contained_{std::forward(t)} @@ -231,7 +291,8 @@ namespace Nui {} template - explicit ModifiableObserved(CustomEventContextFlag_t, EventContext* ctx, T&& t) + requires std::is_constructible_v + ModifiableObserved(CustomEventContextFlag_t, EventContext* ctx, T&& t) : ObservedBase{CustomEventContextFlag, ctx} , contained_{std::forward(t)} {} @@ -269,7 +330,8 @@ namespace Nui requires std::equality_comparable_with && Fundamental && Fundamental ModifiableObserved& operator=(T&& t) { - return assignChecked(t); + assignChecked(std::forward(t)); + return *this; } template @@ -334,7 +396,9 @@ namespace Nui /** * @brief Sets the value without making an update. */ - void assignWithoutUpdate(ContainedT&& t) + template + requires std::constructible_from + void assignWithoutUpdate(T&& t) { contained_ = std::forward(t); } @@ -381,6 +445,8 @@ namespace Nui } return *this; } + ~ReferenceWrapper() = default; + // NOLINTNEXTLINE(hicpp-explicit-conversions) operator T&() { return *ref_; @@ -412,15 +478,25 @@ namespace Nui { return *ref_; } - void operator=(T&& val) + ReferenceWrapper& operator=(T&& val) { *ref_ = std::move(val); owner_->insertRangeChecked(pos_, pos_, RangeOperationType::Modify); + return *this; } - void operator=(T const& val) + ReferenceWrapper& operator=(T const& val) { *ref_ = val; owner_->insertRangeChecked(pos_, pos_, RangeOperationType::Modify); + return *this; + } + bool operator==(ReferenceWrapper const& other) const + { + return *ref_ == *other.ref_; + } + bool operator==(T const& other) const + { + return *ref_ == other; } protected: @@ -457,6 +533,7 @@ namespace Nui , pos_{pos} , ptr_{ptr} {} + // NOLINTNEXTLINE(hicpp-explicit-conversions) operator T&() { return *ptr_; @@ -488,10 +565,11 @@ namespace Nui { return *ptr_; } - void operator=(T* ptr) + PointerWrapper& operator=(T* ptr) { ptr_ = ptr; owner_->insertRangeChecked(pos_, pos_, RangeOperationType::Modify); + return *this; } protected: @@ -519,6 +597,7 @@ namespace Nui IteratorWrapper(IteratorWrapper&&) = default; IteratorWrapper& operator=(IteratorWrapper const&) = default; IteratorWrapper& operator=(IteratorWrapper&&) = default; + ~IteratorWrapper() = default; IteratorWrapper& operator+=(difference_type n) { it_ += n; @@ -668,6 +747,7 @@ namespace Nui , afterEffectId_{registerAfterEffect()} {} template + requires std::constructible_from explicit ObservedContainer(T&& t) : ModifiableObserved{std::forward(t)} , rangeContext_{std::make_shared()} @@ -1302,6 +1382,7 @@ namespace Nui : ObservedContainer>{RangeEventContext{true}} {} template > + requires std::constructible_from, T> explicit Observed(T&& t) : ObservedContainer>{std::forward(t), RangeEventContext{true}} {} @@ -1331,6 +1412,7 @@ namespace Nui : ObservedContainer>{RangeEventContext{true}} {} template > + requires std::constructible_from, T> explicit Observed(T&& t) : ObservedContainer>{std::forward(t), RangeEventContext{true}} {} @@ -1438,8 +1520,8 @@ namespace Nui return observedValue; } template - inline auto - operator--(ModifiableObserved& observedValue, int) -> Detail::PickFirst_t()--)> + inline auto operator--(ModifiableObserved& observedValue, int) + -> Detail::PickFirst_t()--)> { auto tmp = observedValue.value(); --observedValue.value(); @@ -1466,17 +1548,17 @@ namespace Nui : observed_{&observed} {} - inline T const& value() const + T const& value() const { return observed_->value(); } - inline void attachEvent(auto eventId) const + void attachEvent(auto eventId) const { observed_->attachEvent(eventId); } - inline void detachEvent(auto eventId) const + void detachEvent(auto eventId) const { observed_->detachEvent(eventId); } diff --git a/nui/include/nui/event_system/observed_value_combinator.hpp b/nui/include/nui/event_system/observed_value_combinator.hpp index de621515..0d2afcbe 100644 --- a/nui/include/nui/event_system/observed_value_combinator.hpp +++ b/nui/include/nui/event_system/observed_value_combinator.hpp @@ -75,8 +75,7 @@ namespace Nui std::tuple...>&& observedValues() && { - return std::move( - const_cast...>&>(observedValues_)); + return std::move(observedValues_); } bool isAnyExpired() const @@ -98,7 +97,7 @@ namespace Nui } protected: - const std::tuple...> observedValues_; + std::tuple...> observedValues_; }; template @@ -135,7 +134,7 @@ namespace Nui } protected: - const RendererType generator_; + RendererType generator_; }; template @@ -145,7 +144,7 @@ namespace Nui public: using ObservedValueCombinatorWithGenerator:: ObservedValueCombinatorWithGenerator; - ObservedValueCombinatorWithPropertyGenerator( + explicit ObservedValueCombinatorWithPropertyGenerator( ObservedValueCombinatorWithGenerator&& other) : ObservedValueCombinatorWithGenerator{std::move(other)} {} diff --git a/nui/include/nui/event_system/range.hpp b/nui/include/nui/event_system/range.hpp index 2e7a44c2..8190efb2 100644 --- a/nui/include/nui/event_system/range.hpp +++ b/nui/include/nui/event_system/range.hpp @@ -3,8 +3,8 @@ #include #include #include +#include -#include #include #ifdef NUI_HAS_STD_RANGES @@ -49,7 +49,7 @@ namespace Nui : observedValues_{std::move(observedValues)} , rangeLike_{std::move(rangeLike)} {} - UnoptimizedRange(CopyableRangeLike&& rangeLike) + explicit UnoptimizedRange(CopyableRangeLike&& rangeLike) requires(sizeof...(ObservedValues) == 0) : observedValues_{} , rangeLike_{std::move(rangeLike)} diff --git a/nui/include/nui/event_system/range_event_context.hpp b/nui/include/nui/event_system/range_event_context.hpp index 95685191..7861f38a 100644 --- a/nui/include/nui/event_system/range_event_context.hpp +++ b/nui/include/nui/event_system/range_event_context.hpp @@ -7,7 +7,6 @@ #include #include -#include #include #include @@ -34,10 +33,12 @@ namespace Nui using interval_kind = IntervalKind; public: + // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) RangeStateInterval(value_type low, value_type high) : low_{low} , high_{high} {} + // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) void reset(value_type low, value_type high) { low_ = low; @@ -122,8 +123,7 @@ namespace Nui return 0; if (high_ < other.low_) return other.low_ - high_; - else - return low_ - other.high_; + return low_ - other.high_; } value_type size() const { @@ -189,7 +189,7 @@ namespace Nui explicit RangeEventContext() : RangeEventContext(false) {} - RangeEventContext(bool disableOptimizations) + explicit RangeEventContext(bool disableOptimizations) : trackedRanges_{} , operationType_{RangeOperationType::Keep} , nextEraseOverride_{std::nullopt} @@ -216,8 +216,7 @@ namespace Nui return false; if (operationType_ == RangeOperationType::Modify) return eraseModificationFixup(low, high); - else - return eraseInsertionFixup(low, high); + return eraseInsertionFixup(low, high); } bool eraseNotify(std::size_t low, std::size_t high) { @@ -452,10 +451,7 @@ namespace Nui // If the erase interval is left of the last modification interval, we must apply the changes and // retry. An overlap would have been found otherwise. - if (high < lastInterval.low()) - return true; - - return false; + return high < lastInterval.low(); } // find all overlapping modifications and cut them @@ -474,7 +470,8 @@ namespace Nui trackedRanges_.insert({range.high() + 1, modInterval.high()}); return true; // cannot overlap any further } - else if (modInterval.low() < range.low()) + + if (modInterval.low() < range.low()) { // 2. erase starts within modification interval: trackedRanges_.insert({modInterval.low(), range.low() - 1}); diff --git a/nui/include/nui/filesystem/file_dialog_options.hpp b/nui/include/nui/filesystem/file_dialog_options.hpp index 942573ec..1b785855 100644 --- a/nui/include/nui/filesystem/file_dialog_options.hpp +++ b/nui/include/nui/filesystem/file_dialog_options.hpp @@ -20,6 +20,7 @@ namespace Nui::FileDialog }; // This way aggregate initialization can be done without needing to add extra braces +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define COMMON_DIALOG_OPTIONS() \ std::optional title = std::nullopt; \ std::optional defaultPath = std::nullopt; \ diff --git a/nui/include/nui/frontend/api/throttle.hpp b/nui/include/nui/frontend/api/throttle.hpp index 3a2647dc..91098080 100644 --- a/nui/include/nui/frontend/api/throttle.hpp +++ b/nui/include/nui/frontend/api/throttle.hpp @@ -13,9 +13,9 @@ namespace Nui ThrottledFunction(int32_t id, bool calledWhenReady, std::function func); ~ThrottledFunction(); ThrottledFunction(ThrottledFunction const&) = delete; - ThrottledFunction(ThrottledFunction&& other); + ThrottledFunction(ThrottledFunction&& other) noexcept; ThrottledFunction& operator=(ThrottledFunction const&) = delete; - ThrottledFunction& operator=(ThrottledFunction&& other); + ThrottledFunction& operator=(ThrottledFunction&& other) noexcept; /// Calls the function if it is valid. void operator()(); @@ -24,7 +24,7 @@ namespace Nui bool valid() const; private: - int32_t id_{-1}; + int32_t id_; bool calledWhenReady_; std::function func_{}; }; diff --git a/nui/include/nui/frontend/api/timer.hpp b/nui/include/nui/frontend/api/timer.hpp index 8a712428..26b40a5f 100644 --- a/nui/include/nui/frontend/api/timer.hpp +++ b/nui/include/nui/frontend/api/timer.hpp @@ -12,11 +12,11 @@ namespace Nui { public: TimerHandle(); - TimerHandle(int32_t id); + explicit TimerHandle(int32_t id); TimerHandle(const TimerHandle&) = delete; - TimerHandle(TimerHandle&& other); + TimerHandle(TimerHandle&& other) noexcept; TimerHandle& operator=(const TimerHandle&) = delete; - TimerHandle& operator=(TimerHandle&& other); + TimerHandle& operator=(TimerHandle&& other) noexcept; ~TimerHandle(); diff --git a/nui/include/nui/frontend/attributes/impl/attribute.hpp b/nui/include/nui/frontend/attributes/impl/attribute.hpp index 5721736f..2fc3b5c8 100644 --- a/nui/include/nui/frontend/attributes/impl/attribute.hpp +++ b/nui/include/nui/frontend/attributes/impl/attribute.hpp @@ -24,7 +24,7 @@ namespace Nui }; Attribute() = default; - Attribute( + explicit Attribute( std::function setter, std::function&& element)> createEvent = {}, std::function clearEvent = {}) @@ -57,6 +57,7 @@ namespace Nui Attribute(Attribute&&) = default; Attribute& operator=(Attribute const&) = default; Attribute& operator=(Attribute&&) = default; + ~Attribute() = default; void setOn(Dom::ChildlessElement& element) const; EventContext::EventIdType createEvent(std::weak_ptr&& element) const; diff --git a/nui/include/nui/frontend/attributes/impl/attribute_factory.hpp b/nui/include/nui/frontend/attributes/impl/attribute_factory.hpp index 472e3f5e..68772931 100644 --- a/nui/include/nui/frontend/attributes/impl/attribute_factory.hpp +++ b/nui/include/nui/frontend/attributes/impl/attribute_factory.hpp @@ -70,14 +70,11 @@ namespace Nui::Attributes : name_{name} {} - explicit constexpr PropertyFactory(PropertyFactory const& other) - : name_{other.name_} - {} - explicit constexpr PropertyFactory(PropertyFactory&& other) - : name_{other.name_} - {} + constexpr PropertyFactory(PropertyFactory const& other) = default; + constexpr PropertyFactory(PropertyFactory&& other) noexcept = default; PropertyFactory& operator=(PropertyFactory const&) = delete; PropertyFactory& operator=(PropertyFactory&&) = delete; + ~PropertyFactory() = default; constexpr char const* name() const { @@ -88,6 +85,7 @@ namespace Nui::Attributes requires( !IsObservedLike> && !std::invocable && !std::invocable && !Nui::Detail::IsProperty>) + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(U val) const { return Attribute{ @@ -99,6 +97,7 @@ namespace Nui::Attributes template requires(IsSharedObserved>) + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(U const& shared) const { return Attribute{ @@ -106,7 +105,7 @@ namespace Nui::Attributes if (auto shared = weak.lock(); shared) element.setProperty(name, shared->value()); }, - [name = name(), weak = std::weak_ptr{shared}](std::weak_ptr&& element) { + [name = name(), weak = std::weak_ptr{shared}](std::weak_ptr const& element) { auto shared = weak.lock(); if (!shared) return EventContext::invalidEventId; @@ -142,6 +141,7 @@ namespace Nui::Attributes template requires(IsWeakObserved>) + // NOLINTNEXTLINE Attribute operator=(U&& val) const { auto shared = val.lock(); @@ -153,6 +153,7 @@ namespace Nui::Attributes template requires(IsObserved>) + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(U& val) const { return Attribute{ @@ -170,6 +171,7 @@ namespace Nui::Attributes } template + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(ObservedValueCombinatorWithPropertyGenerator const& combinator) const { @@ -187,6 +189,7 @@ namespace Nui::Attributes } template + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(ObservedValueCombinatorWithGenerator const& combinator) const { @@ -203,23 +206,25 @@ namespace Nui::Attributes }; } + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(std::function func) const { return Attribute{ [name = name(), func = std::move(func)](Dom::ChildlessElement& element) { element.setProperty(name, [func](Nui::val val) { - func(val); + func(std::move(val)); globalEventContext.executeActiveEventsImmediately(); }); }, }; } + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(std::function func) const { return Attribute{ [name = name(), func = std::move(func)](Dom::ChildlessElement& element) { - element.setProperty(name, [func](Nui::val) { + element.setProperty(name, [func](Nui::val const&) { func(); globalEventContext.executeActiveEventsImmediately(); }); @@ -238,14 +243,11 @@ namespace Nui::Attributes : name_{name} {} - explicit constexpr AttributeFactory(AttributeFactory const& other) - : name_{other.name_} - {} - explicit constexpr AttributeFactory(AttributeFactory&& other) - : name_{other.name_} - {} + constexpr AttributeFactory(AttributeFactory const& other) = default; + constexpr AttributeFactory(AttributeFactory&& other) = default; AttributeFactory& operator=(AttributeFactory const&) = delete; AttributeFactory& operator=(AttributeFactory&&) = delete; + ~AttributeFactory() = default; constexpr char const* name() const { @@ -256,6 +258,7 @@ namespace Nui::Attributes requires( !IsObservedLike> && !std::invocable && !std::invocable && !Nui::Detail::IsProperty>) + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(U val) const { return Attribute{ @@ -267,6 +270,7 @@ namespace Nui::Attributes template requires(IsSharedObserved>) + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(U const& shared) const { return Attribute{ @@ -274,7 +278,7 @@ namespace Nui::Attributes if (auto shared = weak.lock(); shared) element.setAttribute(name, shared->value()); }, - [name = name(), weak = std::weak_ptr{shared}](std::weak_ptr&& element) { + [name = name(), weak = std::weak_ptr{shared}](std::weak_ptr const& element) { auto shared = weak.lock(); if (!shared) return EventContext::invalidEventId; @@ -310,6 +314,7 @@ namespace Nui::Attributes template requires(IsWeakObserved>) + // NOLINTNEXTLINE Attribute operator=(U&& val) const { auto shared = val.lock(); @@ -321,6 +326,7 @@ namespace Nui::Attributes template requires(IsObserved>) + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(U& val) const { return Attribute{ @@ -339,6 +345,7 @@ namespace Nui::Attributes template requires(IsObserved>) + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(Nui::Detail::Property const& prop) const { return Attribute{ @@ -357,6 +364,7 @@ namespace Nui::Attributes template requires(IsWeakObserved>) + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(Nui::Detail::Property const& prop) const { auto shared = prop.prop.lock(); @@ -368,7 +376,7 @@ namespace Nui::Attributes if (auto shared = weak.lock(); shared) element.setProperty(name, shared->value()); }, - [name = name(), weak = std::weak_ptr{shared}](std::weak_ptr&& element) { + [name = name(), weak = std::weak_ptr{shared}](std::weak_ptr const& element) { auto shared = weak.lock(); if (!shared) return EventContext::invalidEventId; @@ -404,6 +412,7 @@ namespace Nui::Attributes template requires(!IsObservedLike> && !std::invocable && !std::invocable) + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(Nui::Detail::Property const& prop) const { return Attribute{[name = name(), p = std::move(prop.prop)](Dom::ChildlessElement& element) { @@ -412,6 +421,7 @@ namespace Nui::Attributes } template + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(ObservedValueCombinatorWithPropertyGenerator const& combinator) const { @@ -429,6 +439,7 @@ namespace Nui::Attributes } template + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(ObservedValueCombinatorWithGenerator const& combinator) const { @@ -445,23 +456,25 @@ namespace Nui::Attributes }; } + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(std::function func) const { return Attribute{ [name = name(), func = std::move(func)](Dom::ChildlessElement& element) { element.setAttribute(name, [func](Nui::val val) { - func(val); + func(std::move(val)); globalEventContext.executeActiveEventsImmediately(); }); }, }; } + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(std::function func) const { return Attribute{ [name = name(), func = std::move(func)](Dom::ChildlessElement& element) { - element.setAttribute(name, [func](Nui::val) { + element.setAttribute(name, [func](Nui::val const&) { func(); globalEventContext.executeActiveEventsImmediately(); }); @@ -469,23 +482,25 @@ namespace Nui::Attributes }; } + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(Nui::Detail::Property> func) const { return Attribute{ [name = name(), func = std::move(func.prop)](Dom::ChildlessElement& element) { element.setProperty(name, [func](Nui::val val) { - func(val); + func(std::move(val)); globalEventContext.executeActiveEventsImmediately(); }); }, }; } + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(Nui::Detail::Property> func) const { return Attribute{ [name = name(), func = std::move(func.prop)](Dom::ChildlessElement& element) { - element.setProperty(name, [func](Nui::val) { + element.setProperty(name, [func](Nui::val const&) { func(); globalEventContext.executeActiveEventsImmediately(); }); @@ -504,25 +519,23 @@ namespace Nui::Attributes : name_{name} {} - explicit constexpr EventFactory(EventFactory const& other) - : name_{other.name_} - {} - explicit constexpr EventFactory(EventFactory&& other) - : name_{other.name_} - {} + constexpr EventFactory(EventFactory const& other) = default; + constexpr EventFactory(EventFactory&& other) = default; EventFactory& operator=(EventFactory const&) = delete; EventFactory& operator=(EventFactory&&) = delete; + ~EventFactory() = default; constexpr char const* name() const { return name_; }; + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(std::function func) const { return Attribute{ [name = name(), func = std::move(func)](Dom::ChildlessElement& element) { - element.addEventListener(name, [func](Nui::val) { + element.addEventListener(name, [func](Nui::val const&) { func(); globalEventContext.executeActiveEventsImmediately(); }); @@ -530,6 +543,7 @@ namespace Nui::Attributes }; } + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(std::function func) const { return Attribute{ @@ -570,6 +584,7 @@ namespace Nui::Attributes T factory; template + // NOLINTNEXTLINE(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature) Attribute operator=(Args&&... args) const { auto attr = factory.operator=(std::forward(args)...); @@ -588,6 +603,7 @@ namespace Nui::Attributes } } +// NOLINTBEGIN #define MAKE_HTML_VALUE_ATTRIBUTE_RENAME(NAME, HTML_NAME) \ namespace Nui::Attributes \ { \ @@ -605,5 +621,6 @@ namespace Nui::Attributes } \ static constexpr auto NAME = AttributeFactory{Names::Attr##NAME}; \ } +// NOLINTEND #define MAKE_HTML_EVENT_ATTRIBUTE(NAME) MAKE_HTML_EVENT_ATTRIBUTE_RENAME(NAME, #NAME) \ No newline at end of file diff --git a/nui/include/nui/frontend/components/dialog.hpp b/nui/include/nui/frontend/components/dialog.hpp index fd47b1a6..2bd48ef0 100644 --- a/nui/include/nui/frontend/components/dialog.hpp +++ b/nui/include/nui/frontend/components/dialog.hpp @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -33,9 +32,9 @@ namespace Nui::Components struct ConstructionArgs { std::optional className{std::nullopt}; - std::string title{""}; - std::string body{""}; - std::string buttonClassName{""}; + std::string title{}; + std::string body{}; + std::string buttonClassName{}; ButtonConfiguration buttonConfiguration{ButtonConfiguration::Ok}; std::function onButtonClicked = [](Button) {}; }; @@ -45,7 +44,7 @@ namespace Nui::Components * * @param args The intial values for the dialog. */ - DialogController(ConstructionArgs&& args); + explicit DialogController(ConstructionArgs&& args); /** * @brief Shows the dialog as a modal dialog (blocks the UI). diff --git a/nui/include/nui/frontend/components/table.hpp b/nui/include/nui/frontend/components/table.hpp index 6e2c6395..9b38a6b8 100644 --- a/nui/include/nui/frontend/components/table.hpp +++ b/nui/include/nui/frontend/components/table.hpp @@ -10,9 +10,7 @@ #include #include -#include #include -#include #include namespace Nui::Components diff --git a/nui/include/nui/frontend/dom/basic_element.hpp b/nui/include/nui/frontend/dom/basic_element.hpp index 4a11aca2..691068e2 100644 --- a/nui/include/nui/frontend/dom/basic_element.hpp +++ b/nui/include/nui/frontend/dom/basic_element.hpp @@ -17,6 +17,10 @@ namespace Nui::Dom : element_{std::move(val)} {} virtual ~BasicElement() = default; + BasicElement(BasicElement const&) = default; + BasicElement(BasicElement&&) noexcept = default; + BasicElement& operator=(BasicElement const&) = default; + BasicElement& operator=(BasicElement&&) noexcept = default; Nui::val const& val() const { @@ -26,14 +30,17 @@ namespace Nui::Dom { return element_; } + // NOLINTNEXTLINE(hicpp-explicit-conversions) operator Nui::val const&() const { return element_; } + // NOLINTNEXTLINE(hicpp-explicit-conversions) operator Nui::val&() { return element_; } + // NOLINTNEXTLINE(hicpp-explicit-conversions) operator Nui::val&&() && { return std::move(element_); diff --git a/nui/include/nui/frontend/dom/dom.hpp b/nui/include/nui/frontend/dom/dom.hpp index 8e5bf4fb..28246743 100644 --- a/nui/include/nui/frontend/dom/dom.hpp +++ b/nui/include/nui/frontend/dom/dom.hpp @@ -4,7 +4,7 @@ #include #include -#include +#include namespace Nui::Dom { diff --git a/nui/include/nui/frontend/dom/element.hpp b/nui/include/nui/frontend/dom/element.hpp index 15a572e5..c105296c 100644 --- a/nui/include/nui/frontend/dom/element.hpp +++ b/nui/include/nui/frontend/dom/element.hpp @@ -78,7 +78,7 @@ namespace Nui::Dom Element& operator=(Element const&) = delete; Element& operator=(Element&&) = delete; - ~Element() + ~Element() override { clearChildren(); destroy_(element_); @@ -277,8 +277,7 @@ namespace Nui::Dom { if (where >= children_.size()) return appendElement(element); - else - return insert(begin() + static_cast(where), element); + return insert(begin() + static_cast(where), element); } auto& operator[](std::size_t index) diff --git a/nui/include/nui/frontend/dom/reference.hpp b/nui/include/nui/frontend/dom/reference.hpp index a36eab52..e46f460d 100644 --- a/nui/include/nui/frontend/dom/reference.hpp +++ b/nui/include/nui/frontend/dom/reference.hpp @@ -2,7 +2,6 @@ #include -#include #include #include #include diff --git a/nui/include/nui/frontend/elements/detail/fragment_context.hpp b/nui/include/nui/frontend/elements/detail/fragment_context.hpp index 3f210cd4..5a21a46b 100644 --- a/nui/include/nui/frontend/elements/detail/fragment_context.hpp +++ b/nui/include/nui/frontend/elements/detail/fragment_context.hpp @@ -1,5 +1,8 @@ #pragma once +#include +#include + namespace Nui::Detail { template diff --git a/nui/include/nui/frontend/elements/impl/html_element.hpp b/nui/include/nui/frontend/elements/impl/html_element.hpp index bd4a5ec1..6a58154a 100644 --- a/nui/include/nui/frontend/elements/impl/html_element.hpp +++ b/nui/include/nui/frontend/elements/impl/html_element.hpp @@ -21,8 +21,6 @@ #include #include #include -#include -#include namespace Nui { @@ -49,7 +47,7 @@ namespace Nui struct TrivialRenderer { public: - TrivialRenderer(HtmlElem htmlElement); + explicit TrivialRenderer(HtmlElem htmlElement); std::shared_ptr operator()(Dom::Element& parentElement, Renderer const& gen) const; private: @@ -63,7 +61,10 @@ namespace Nui HtmlElement(HtmlElement const&) = default; HtmlElement(HtmlElement&&) = default; + HtmlElement& operator=(HtmlElement const&) = default; + HtmlElement& operator=(HtmlElement&&) = default; virtual ~HtmlElement() = default; + HtmlElement(char const* name, HtmlElementBridge const* bridge, std::vector const& attributes) : name_{name} , bridge_{bridge} @@ -158,12 +159,13 @@ namespace Nui } template + // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) auto rangeRender(RangeType&& valueRange, GeneratorT&& elementRenderer) && { return [self = this->clone(), rangeRenderer = std::make_shared< Detail::RangeRenderer, GeneratorT, RangeType::isRandomAccess>>( - std::move(valueRange).underlying(), std::forward(elementRenderer))]( + std::forward(valueRange).underlying(), std::forward(elementRenderer))]( auto& parentElement, Renderer const& gen) mutable { if (gen.type == RendererType::Inplace) throw std::runtime_error("fragments are not supported for range generators"); @@ -202,7 +204,7 @@ namespace Nui } // Trivial case: - auto operator()() && + auto operator()() const&& { return std::function(Dom::Element&, Renderer const&)>{ TrivialRenderer{this->clone()}}; @@ -224,7 +226,7 @@ namespace Nui return materialized; }; } - auto operator()(std::string_view view) && + auto operator()(std::string_view view) const&& { return [self = this->clone(), view](auto& parentElement, Renderer const& gen) { auto materialized = renderElement(gen, parentElement, self); @@ -232,7 +234,7 @@ namespace Nui return materialized; }; } - auto operator()(char const* text) && + auto operator()(char const* text) const&& { return [self = this->clone(), text](auto& parentElement, Renderer const& gen) { auto materialized = renderElement(gen, parentElement, self); @@ -311,6 +313,7 @@ namespace Nui return std::move(*this).rangeRender(std::move(mapPair.first), std::move(mapPair.second)); } template + // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward): false positive auto operator()(UnoptimizedRange&& unoptimizedRange, GeneratorT&& elementRenderer) && { return [self = this->clone(), @@ -328,7 +331,7 @@ namespace Nui } // Observed text and number content functions: - inline auto operator()(Observed const& observedString) && + auto operator()(Observed const& observedString) && { return std::move(*this).operator()(observe(observedString), [&observedString]() -> std::string { return observedString.value(); @@ -343,17 +346,17 @@ namespace Nui }); } - inline std::vector const& attributes() const + std::vector const& attributes() const { return attributes_; } - inline char const* name() const + char const* name() const { return name_; } - inline HtmlElementBridge const* bridge() const + HtmlElementBridge const* bridge() const { return bridge_; } diff --git a/nui/include/nui/frontend/elements/impl/html_element.tpp b/nui/include/nui/frontend/elements/impl/html_element.tpp index d072be96..3a949e67 100644 --- a/nui/include/nui/frontend/elements/impl/html_element.tpp +++ b/nui/include/nui/frontend/elements/impl/html_element.tpp @@ -36,6 +36,7 @@ namespace Nui } } +// NOLINTBEGIN #define NUI_MAKE_HTML_ELEMENT_RENAME(NAME, HTML_ACTUAL) \ struct NAME : ::Nui::HtmlElement \ { \ @@ -61,4 +62,5 @@ namespace Nui NUI_MAKE_HTML_ELEMENT_RENAME(NAME, HTML_ACTUAL) \ } -#define NUI_DECLARE_HTML_ELEMENT(NAME) NUI_DECLARE_HTML_ELEMENT_RENAME(NAME, #NAME) \ No newline at end of file +#define NUI_DECLARE_HTML_ELEMENT(NAME) NUI_DECLARE_HTML_ELEMENT_RENAME(NAME, #NAME) +// NOLINTEND \ No newline at end of file diff --git a/nui/include/nui/frontend/elements/impl/materialize.hpp b/nui/include/nui/frontend/elements/impl/materialize.hpp index 8fd19fc9..89bea764 100644 --- a/nui/include/nui/frontend/elements/impl/materialize.hpp +++ b/nui/include/nui/frontend/elements/impl/materialize.hpp @@ -1,3 +1,8 @@ +#include + +#include +#include + namespace Nui { class HtmlElement; diff --git a/nui/src/nui/backend/filesystem/file_dialog_options.cpp b/nui/src/nui/backend/filesystem/file_dialog_options.cpp index 6b556a15..ae7a4dd4 100644 --- a/nui/src/nui/backend/filesystem/file_dialog_options.cpp +++ b/nui/src/nui/backend/filesystem/file_dialog_options.cpp @@ -2,33 +2,36 @@ namespace Nui::FileDialog { - //##################################################################################################################### - template - void to_json_common(nlohmann::json& json, T const& options) + // ##################################################################################################################### + namespace { - if (options.title) - json["title"] = *options.title; - if (options.defaultPath) - json["defaultPath"] = options.defaultPath->string(); - json["filters"] = options.filters; - json["forcePath"] = options.forcePath; - } - //--------------------------------------------------------------------------------------------------------------------- - template - void from_json_common(nlohmann::json const& json, T& options) - { - if (json.contains("title")) - options.title = json["title"].get(); - else - options.title = std::nullopt; + template + void to_json_common(nlohmann::json& json, T const& options) + { + if (options.title) + json["title"] = *options.title; + if (options.defaultPath) + json["defaultPath"] = options.defaultPath->string(); + json["filters"] = options.filters; + json["forcePath"] = options.forcePath; + } + //--------------------------------------------------------------------------------------------------------------------- + template + void from_json_common(nlohmann::json const& json, T& options) + { + if (json.contains("title")) + options.title = json["title"].get(); + else + options.title = std::nullopt; - if (json.contains("defaultPath")) - options.defaultPath = json["defaultPath"].get(); - else - options.defaultPath = std::nullopt; + if (json.contains("defaultPath")) + options.defaultPath = json["defaultPath"].get(); + else + options.defaultPath = std::nullopt; - json.at("filters").get_to(options.filters); - json.at("forcePath").get_to(options.forcePath); + json.at("filters").get_to(options.filters); + json.at("forcePath").get_to(options.forcePath); + } } //--------------------------------------------------------------------------------------------------------------------- void to_json(nlohmann::json& json, OpenDialogOptions const& options) @@ -64,5 +67,5 @@ namespace Nui::FileDialog from_json_common(json, options); options.forceOverwrite = json["forceOverwrite"].get(); } - //##################################################################################################################### + // ##################################################################################################################### } \ No newline at end of file diff --git a/nui/src/nui/frontend/api/throttle.cpp b/nui/src/nui/frontend/api/throttle.cpp index db251e61..0e22c5c6 100644 --- a/nui/src/nui/frontend/api/throttle.cpp +++ b/nui/src/nui/frontend/api/throttle.cpp @@ -27,14 +27,15 @@ namespace Nui } } //--------------------------------------------------------------------------------------------------------------------- - ThrottledFunction::ThrottledFunction(ThrottledFunction&& other) + ThrottledFunction::ThrottledFunction(ThrottledFunction&& other) noexcept : id_(other.id_) + , calledWhenReady_{other.calledWhenReady_} , func_(std::move(other.func_)) { other.id_ = -1; } //--------------------------------------------------------------------------------------------------------------------- - ThrottledFunction& ThrottledFunction::operator=(ThrottledFunction&& other) + ThrottledFunction& ThrottledFunction::operator=(ThrottledFunction&& other) noexcept { id_ = other.id_; func_ = std::move(other.func_); diff --git a/nui/src/nui/frontend/api/timer.cpp b/nui/src/nui/frontend/api/timer.cpp index f176c9e6..feab49ea 100644 --- a/nui/src/nui/frontend/api/timer.cpp +++ b/nui/src/nui/frontend/api/timer.cpp @@ -18,13 +18,13 @@ namespace Nui stop(); } //--------------------------------------------------------------------------------------------------------------------- - TimerHandle::TimerHandle(TimerHandle&& other) + TimerHandle::TimerHandle(TimerHandle&& other) noexcept : id_{other.id_} { other.id_ = -1; } //--------------------------------------------------------------------------------------------------------------------- - TimerHandle& TimerHandle::operator=(TimerHandle&& other) + TimerHandle& TimerHandle::operator=(TimerHandle&& other) noexcept { id_ = other.id_; other.id_ = -1; diff --git a/nui/src/nui/frontend/utility/fragment_listener.cpp b/nui/src/nui/frontend/utility/fragment_listener.cpp index 2dd869f3..adfeb52c 100644 --- a/nui/src/nui/frontend/utility/fragment_listener.cpp +++ b/nui/src/nui/frontend/utility/fragment_listener.cpp @@ -16,7 +16,8 @@ namespace Nui fragment = Nui::val::global("location")["hash"].as(); else fragment = ""; - if (fragment.front() == '#') + + if (fragment.value().front() == '#') fragment.erase(0, 1); Nui::val::global("window").call(