Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[base] Code cleanup #7699

Merged
merged 1 commit into from
Apr 17, 2024
Merged

Conversation

AndrewShkrob
Copy link
Member

Removed includes
Removed namespaces
Fixed formatting (empty lines, template functions)

These changes are based on clang-tidy in IDE

@AndrewShkrob AndrewShkrob added the Core Cross-platform C++ libraries with a core functionality label Mar 26, 2024
@AndrewShkrob AndrewShkrob requested a review from vng March 26, 2024 18:53
@biodranik
Copy link
Member

Linux check is failing. @vng I would also like to see a clean code in CLion Nova.

Copy link
Contributor

@rtsisyk rtsisyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@@ -71,7 +74,7 @@ template <class T, size_t N> class buffer_vector

buffer_vector(buffer_vector const &) = default;

buffer_vector(buffer_vector && rhs) : m_size(rhs.m_size), m_dynamic(std::move(rhs.m_dynamic))
buffer_vector(buffer_vector && rhs) noexcept : m_size(rhs.m_size), m_dynamic(std::move(rhs.m_dynamic))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noexceptness here and below should probably depend on T.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, yes, actually it should depend on T(T&&) noexcept

  1. Simple one: add static_assert(noexcept(T()));
  2. Complex one: add enable_if blah-blah

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noexcept(std::is_nothrow_constructible_v<T, T>)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Does it check T() and T(T&&) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about noexcept(std::is_nothrow_constructible_v<T, T>)
I'd better revert this change, because I don't have time to investigate it right now

Copy link
Member

@vng vng Mar 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctor and operator= both use MoveStatic, which uses std::move algo, so should be enough:

static_assert(std::is_nothrow_move_assignable<T>::value);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did and pushed it myself.

base/control_flow.hpp Outdated Show resolved Hide resolved
base/normalize_unicode.cpp Show resolved Hide resolved
base/levenshtein_dfa.cpp Outdated Show resolved Hide resolved
base/gmtime.hpp Show resolved Hide resolved
@@ -71,7 +74,7 @@ template <class T, size_t N> class buffer_vector

buffer_vector(buffer_vector const &) = default;

buffer_vector(buffer_vector && rhs) : m_size(rhs.m_size), m_dynamic(std::move(rhs.m_dynamic))
buffer_vector(buffer_vector && rhs) noexcept : m_size(rhs.m_size), m_dynamic(std::move(rhs.m_dynamic))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, yes, actually it should depend on T(T&&) noexcept

  1. Simple one: add static_assert(noexcept(T()));
  2. Complex one: add enable_if blah-blah

base/buffer_vector.hpp Outdated Show resolved Hide resolved
base/string_utils.cpp Outdated Show resolved Hide resolved
@AndrewShkrob AndrewShkrob force-pushed the cleanup/base branch 2 times, most recently from 9da7570 to 7c69319 Compare March 30, 2024 09:03
@@ -81,7 +84,7 @@ template <class T, size_t N> class buffer_vector

buffer_vector & operator=(buffer_vector const & rhs) = default;

buffer_vector & operator=(buffer_vector && rhs)
buffer_vector & operator=(buffer_vector && rhs) noexcept
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you reverted ctor, remove here also. They both use MoveStatic function.

base/levenshtein_dfa.cpp Outdated Show resolved Hide resolved
Signed-off-by: Andrew Shkrob <andrew.shkrob.social@yandex.by>
Copy link
Member

@biodranik biodranik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanup!

@biodranik biodranik merged commit 2bbe4f9 into organicmaps:master Apr 17, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Cross-platform C++ libraries with a core functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants