Skip to content

Commit

Permalink
Merge pull request eclipse-iceoryx#916 from ApexAI/iox-#902-apply-noe…
Browse files Browse the repository at this point in the history
…xcept-all-the-things

iox-eclipse-iceoryx#902 Apply `noexcept` all the things rule to posh, hoofs and binding_c
  • Loading branch information
mossmaurice authored Sep 14, 2021
2 parents 777a76e + 1569466 commit 78541c4
Show file tree
Hide file tree
Showing 156 changed files with 562 additions and 540 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

namespace c2cpp
{
iox::popo::SubscriberTooSlowPolicy subscriberTooSlowPolicy(const ENUM iox_SubscriberTooSlowPolicy policy);
iox::popo::QueueFullPolicy queueFullPolicy(const ENUM iox_QueueFullPolicy policy);
iox::popo::SubscriberTooSlowPolicy subscriberTooSlowPolicy(const ENUM iox_SubscriberTooSlowPolicy policy) noexcept;
iox::popo::QueueFullPolicy queueFullPolicy(const ENUM iox_QueueFullPolicy policy) noexcept;
iox::popo::SubscriberEvent subscriberEvent(const iox_SubscriberEvent value) noexcept;
iox::popo::SubscriberState subscriberState(const iox_SubscriberState value) noexcept;
} // namespace c2cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ iox_ChunkReceiveResult chunkReceiveResult(const iox::popo::ChunkReceiveResult va
iox_AllocationResult allocationResult(const iox::popo::AllocationError value) noexcept;
iox_WaitSetResult waitSetResult(const iox::popo::WaitSetError value) noexcept;
iox_ListenerResult listenerResult(const iox::popo::ListenerError value) noexcept;
iox_SubscriberTooSlowPolicy subscriberTooSlowPolicy(const iox::popo::SubscriberTooSlowPolicy policy);
iox_QueueFullPolicy queueFullPolicy(const iox::popo::QueueFullPolicy policy);
iox_SubscriberTooSlowPolicy subscriberTooSlowPolicy(const iox::popo::SubscriberTooSlowPolicy policy) noexcept;
iox_QueueFullPolicy queueFullPolicy(const iox::popo::QueueFullPolicy policy) noexcept;
} // namespace cpp2c

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

struct cpp2c_Publisher
{
cpp2c_Publisher() = default;
cpp2c_Publisher() noexcept = default;
cpp2c_Publisher(const cpp2c_Publisher&) = delete;
cpp2c_Publisher(cpp2c_Publisher&& rhs) noexcept;
~cpp2c_Publisher();
~cpp2c_Publisher() noexcept;

cpp2c_Publisher& operator=(const cpp2c_Publisher&) = delete;
cpp2c_Publisher& operator=(cpp2c_Publisher&& rhs) noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@

struct cpp2c_Subscriber
{
cpp2c_Subscriber() = default;
cpp2c_Subscriber() noexcept = default;
cpp2c_Subscriber(const cpp2c_Subscriber&) = delete;
cpp2c_Subscriber(cpp2c_Subscriber&& rhs) = delete;
~cpp2c_Subscriber();
~cpp2c_Subscriber() noexcept;

cpp2c_Subscriber& operator=(const cpp2c_Subscriber&) = delete;
cpp2c_Subscriber& operator=(cpp2c_Subscriber&& rhs) = delete;
Expand Down
4 changes: 2 additions & 2 deletions iceoryx_binding_c/source/c2cpp_enum_translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace c2cpp
{
iox::popo::SubscriberTooSlowPolicy subscriberTooSlowPolicy(const ENUM iox_SubscriberTooSlowPolicy policy)
iox::popo::SubscriberTooSlowPolicy subscriberTooSlowPolicy(const ENUM iox_SubscriberTooSlowPolicy policy) noexcept
{
switch (policy)
{
Expand All @@ -35,7 +35,7 @@ iox::popo::SubscriberTooSlowPolicy subscriberTooSlowPolicy(const ENUM iox_Subscr
return iox::popo::SubscriberTooSlowPolicy::DISCARD_OLDEST_DATA;
}

iox::popo::QueueFullPolicy queueFullPolicy(const ENUM iox_QueueFullPolicy policy)
iox::popo::QueueFullPolicy queueFullPolicy(const ENUM iox_QueueFullPolicy policy) noexcept
{
switch (policy)
{
Expand Down
4 changes: 2 additions & 2 deletions iceoryx_binding_c/source/cpp2c_enum_translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ iox_ListenerResult listenerResult(const iox::popo::ListenerError value) noexcept
return ListenerResult_UNDEFINED_ERROR;
}

iox_SubscriberTooSlowPolicy subscriberTooSlowPolicy(const iox::popo::SubscriberTooSlowPolicy policy)
iox_SubscriberTooSlowPolicy subscriberTooSlowPolicy(const iox::popo::SubscriberTooSlowPolicy policy) noexcept
{
switch (policy)
{
Expand All @@ -112,7 +112,7 @@ iox_SubscriberTooSlowPolicy subscriberTooSlowPolicy(const iox::popo::SubscriberT
}
return SubscriberTooSlowPolicy_DISCARD_OLDEST_DATA;
}
iox_QueueFullPolicy queueFullPolicy(const iox::popo::QueueFullPolicy policy)
iox_QueueFullPolicy queueFullPolicy(const iox::popo::QueueFullPolicy policy) noexcept
{
switch (policy)
{
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_binding_c/source/cpp2c_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cpp2c_Publisher::cpp2c_Publisher(cpp2c_Publisher&& rhs) noexcept
*this = std::move(rhs);
}

cpp2c_Publisher::~cpp2c_Publisher()
cpp2c_Publisher::~cpp2c_Publisher() noexcept
{
if (m_portData)
{
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_binding_c/source/cpp2c_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

using namespace iox::popo;

cpp2c_Subscriber::~cpp2c_Subscriber()
cpp2c_Subscriber::~cpp2c_Subscriber() noexcept
{
if (m_portData)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class LockFreeQueue
/// @brief creates and initalizes an empty LockFreeQueue
LockFreeQueue() noexcept;

~LockFreeQueue() = default;
~LockFreeQueue() noexcept = default;

// remark: a thread-safe and lockfree implementation of copy seems impossible
// but unsafe copying (i.e. where synchronization is up to the user) would be possible
Expand Down Expand Up @@ -118,13 +118,13 @@ class LockFreeQueue
// template is needed to distinguish between lvalue and rvalue T references
// (universal reference type deduction)
template <typename T>
void writeBufferAt(const BufferIndex&, T&&);
void writeBufferAt(const BufferIndex&, T&&) noexcept;

// needed to avoid code duplication (via universal reference type deduction)
template <typename T>
iox::cxx::optional<ElementType> pushImpl(T&& value) noexcept;

cxx::optional<ElementType> readBufferAt(const BufferIndex&);
cxx::optional<ElementType> readBufferAt(const BufferIndex&) noexcept;
};
} // namespace concurrent
} // namespace iox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class ResizeableLockFreeQueue : protected LockFreeQueue<ElementType, MaxCapacity
using element_t = ElementType;
static constexpr uint64_t MAX_CAPACITY = MaxCapacity;

ResizeableLockFreeQueue() = default;
~ResizeableLockFreeQueue() = default;
ResizeableLockFreeQueue() noexcept = default;
~ResizeableLockFreeQueue() noexcept = default;

// deleted for now, can be implemented later if needed
// note: concurrent copying or moving in lockfree fashion is nontrivial
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/include/iceoryx_hoofs/cxx/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ constexpr bool doesContainType() noexcept;
/// @param T type of the value to check
/// @return always false
template <typename T>
inline constexpr bool doesContainValue(const T);
inline constexpr bool doesContainValue(const T) noexcept;

/// @brief Returns true if value of T is found in the ValueList, otherwise false
/// @tparam T type of the value to check
Expand Down
10 changes: 5 additions & 5 deletions iceoryx_hoofs/include/iceoryx_hoofs/cxx/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class convert
/// @return string representation of t
template <typename Source>
static typename std::enable_if<!std::is_convertible<Source, std::string>::value, std::string>::type
toString(const Source& t);
toString(const Source& t) noexcept;

/// @brief Converts every type which is either a pod (plain old data) type or is convertable
/// to a string (this means that the operator std::string() is defined)
Expand All @@ -71,24 +71,24 @@ class convert
/// @return string representation of t
template <typename Source>
static typename std::enable_if<std::is_convertible<Source, std::string>::value, std::string>::type
toString(const Source& t);
toString(const Source& t) noexcept;

/// @brief Sets dest from a given string. If the conversion fails false is
/// returned and the value of dest is undefined.
/// @param[in] v string which contains the value of dest
/// @param[in] dest destination to which the value should be written
/// @return false = if the conversion fails otherwise true
template <typename Destination>
static bool fromString(const char* v, Destination& dest);
static bool fromString(const char* v, Destination& dest) noexcept;

/// @brief checks if a given string v is a number
/// @param[in] v string which contains the number
/// @param[in] type is the expected contained type in v
/// @return true if the given string is a number, otherwise false
static bool stringIsNumber(const char* v, const NumberType type);
static bool stringIsNumber(const char* v, const NumberType type) noexcept;

private:
static bool stringIsNumberWithErrorMessage(const char* v, const NumberType type);
static bool stringIsNumberWithErrorMessage(const char* v, const NumberType type) noexcept;
};

} // namespace cxx
Expand Down
6 changes: 3 additions & 3 deletions iceoryx_hoofs/include/iceoryx_hoofs/cxx/expected.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ class IOX_NO_DISCARD expected<ErrorType>
#endif
/// @brief calls the destructor of the success value or error value - depending on what
/// is stored in the expected
~expected() = default;
~expected() noexcept = default;

/// @brief calls the copy assignment operator of the contained success value
/// or the error value - depending on what is stored in the expected
expected& operator=(const expected&);
expected& operator=(const expected&) noexcept;

/// @brief calls the move assignment operator of the contained success value
/// or the error value - depending on what is stored in the expected
Expand Down Expand Up @@ -321,7 +321,7 @@ class IOX_NO_DISCARD expected<ValueType, ErrorType>

/// @brief the copy constructor calls the copy constructor of the contained success value
/// or the error value - depending on what is stored in the expected
expected(const expected&) = default;
expected(const expected&) noexcept = default;

/// @brief the move constructor calls the move constructor of the contained success value
/// or the error value - depending on what is stored in the expected
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/include/iceoryx_hoofs/cxx/forward_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class forward_list

/// @brief destructs the list and also calls the destructor of all
/// contained elements
~forward_list();
~forward_list() noexcept;

/// @brief copy constructor list including elements
/// @param[in] rhs is the list to copy from (same capacity)
Expand Down
38 changes: 19 additions & 19 deletions iceoryx_hoofs/include/iceoryx_hoofs/cxx/helplets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ struct TruncateToCapacity_t;

namespace internal
{
inline void
Require(const bool condition, const char* file, const int line, const char* function, const char* conditionString)
inline void Require(
const bool condition, const char* file, const int line, const char* function, const char* conditionString) noexcept
{
if (!condition)
{
Expand Down Expand Up @@ -99,13 +99,13 @@ template <typename T, typename = typename std::enable_if<std::is_pointer<T>::val
struct not_null
{
public:
not_null(T t)
not_null(T t) noexcept
: value(t)
{
Expects(t != nullptr);
}

constexpr operator T() const
constexpr operator T() const noexcept
{
return value;
}
Expand All @@ -118,13 +118,13 @@ template <typename T, T Minimum>
struct greater_or_equal
{
public:
greater_or_equal(T t)
greater_or_equal(T t) noexcept
: value(t)
{
Expects(t >= Minimum);
}

constexpr operator T() const
constexpr operator T() const noexcept
{
return value;
}
Expand All @@ -137,13 +137,13 @@ template <typename T, T Minimum, T Maximum>
struct range
{
public:
range(T t)
range(T t) noexcept
: value(t)
{
Expects(t >= Minimum && t <= Maximum);
}

constexpr operator T() const
constexpr operator T() const noexcept
{
return value;
}
Expand All @@ -153,7 +153,7 @@ struct range
};

template <typename T>
T align(const T value, const T alignment)
T align(const T value, const T alignment) noexcept
{
T remainder = value % alignment;
return value + ((remainder == 0u) ? 0u : alignment - remainder);
Expand All @@ -167,46 +167,46 @@ void* alignedAlloc(const uint64_t alignment, const uint64_t size) noexcept;

/// @brief frees aligned memory allocated with alignedAlloc
/// @param[in] memory, pointer to the aligned memory
void alignedFree(void* const memory);
void alignedFree(void* const memory) noexcept;

/// template recursion stopper for maximum alignment calculation
template <size_t s = 0>
constexpr size_t maxAlignment()
constexpr size_t maxAlignment() noexcept
{
return s;
}

/// calculate maximum alignment of supplied types
template <typename T, typename... Args>
constexpr size_t maxAlignment()
constexpr size_t maxAlignment() noexcept
{
return alignof(T) > maxAlignment<Args...>() ? alignof(T) : maxAlignment<Args...>();
}

/// template recursion stopper for maximum size calculation
template <size_t s = 0>
constexpr size_t maxSize()
constexpr size_t maxSize() noexcept
{
return s;
}

/// calculate maximum size of supplied types
template <typename T, typename... Args>
constexpr size_t maxSize()
constexpr size_t maxSize() noexcept
{
return sizeof(T) > maxSize<Args...>() ? sizeof(T) : maxSize<Args...>();
}

/// Convert Enum class type to string
template <typename T, typename Enumeration>
const char* convertEnumToString(T port, const Enumeration source)
const char* convertEnumToString(T port, const Enumeration source) noexcept
{
return port[static_cast<size_t>(source)];
}

/// cast an enum to its underlying type
template <typename enum_type>
auto enumTypeAsUnderlyingType(enum_type const value) -> typename std::underlying_type<enum_type>::type
auto enumTypeAsUnderlyingType(enum_type const value) noexcept -> typename std::underlying_type<enum_type>::type
{
return static_cast<typename std::underlying_type<enum_type>::type>(value);
}
Expand All @@ -230,7 +230,7 @@ void forEach(Container& c, const Functor& f) noexcept
/// @param[in] The actual content of the char array is not of interest. Its just the size of the array that matters.
/// @return Returns the size of a char array at compile time.
template <uint64_t SizeValue>
static constexpr uint64_t strlen2(char const (&/*notInterested*/)[SizeValue])
static constexpr uint64_t strlen2(char const (&/*notInterested*/)[SizeValue]) noexcept
{
return SizeValue - 1;
}
Expand All @@ -253,15 +253,15 @@ using BestFittingType_t = typename BestFittingType<Value>::Type_t;

/// @brief Returns info whether called on a 32-bit system
/// @return True if called on 32-bit, false if not 32-bit system
constexpr bool isCompiledOn32BitSystem()
constexpr bool isCompiledOn32BitSystem() noexcept
{
return INTPTR_MAX == INT32_MAX;
}

/// @brief Checks if an unsigned integer is a power of two
/// @return true if power of two, otherwise false
template <typename T>
constexpr bool isPowerOfTwo(const T n)
constexpr bool isPowerOfTwo(const T n) noexcept
{
static_assert(std::is_unsigned<T>::value && !std::is_same<T, bool>::value, "Only unsigned integer are allowed!");
return n && ((n & (n - 1U)) == 0U);
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/include/iceoryx_hoofs/cxx/list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class list

/// @brief destructs the list and also calls the destructor of all
/// contained elements
~list();
~list() noexcept;

/// @brief copy constructor list including elements
/// @param[in] rhs is the list to copy from (same capacity)
Expand Down
Loading

0 comments on commit 78541c4

Please sign in to comment.