Compare commits

..

No commits in common. "3aca35788b247974c5a3a7a0f023f6a01bb71c7e" and "0ba9416a57c86feb5dbbac8439e9775742043227" have entirely different histories.

5 changed files with 2 additions and 67 deletions

View File

@ -28,7 +28,6 @@ add_executable(tests
function.cpp
assert_ndebug.cpp
assert.cpp
enum_helpers.cpp
)
target_link_libraries(tests

View File

@ -1,41 +0,0 @@
//
// Created by erki on 15.07.22.
//
#include <catch2/catch.hpp>
#include "utility_enum_helpers.hpp"
namespace
{
enum class TestEnum : unsigned
{
FLAG_0 = 1,
FLAG_1 = 2,
FLAG_2 = 4
};
SKULLC_ENUM_DECLARE_BITFLAG_OPERATORS(TestEnum)
}// namespace
TEST_CASE("OR operator works as expected.", "[utility],[enum_helpers]")
{
const TestEnum a = TestEnum::FLAG_0;
const TestEnum b = TestEnum::FLAG_1;
const TestEnum sum = a | b;
CHECK(unsigned(sum) == 3u);
}
TEST_CASE("AND operator works as expected.", "[utility],[enum_helpers]")
{
const TestEnum a = TestEnum::FLAG_0 | TestEnum::FLAG_1;
const TestEnum masked_1 = a & TestEnum::FLAG_0;
CHECK(masked_1 == TestEnum::FLAG_0);
const TestEnum masked_2 = a & TestEnum::FLAG_2;
CHECK(masked_2 != TestEnum::FLAG_2);
}

View File

@ -1,20 +0,0 @@
//
// Created by erki on 15.07.22.
//
#ifndef SKULLC_UTILITY_ENUM_HELPERS_HPP_
#define SKULLC_UTILITY_ENUM_HELPERS_HPP_
#define SKULLC_ENUM_DECLARE_BITFLAG_OPERATORS(E) \
inline E operator|(const E& lhs, const E& rhs) \
{ \
using T = std::underlying_type_t<E>; \
return static_cast<E>(static_cast<T>(lhs) | static_cast<T>(rhs)); \
} \
inline E operator&(const E& lhs, const E& rhs) \
{ \
using T = std::underlying_type_t<E>; \
return static_cast<E>(static_cast<T>(lhs) & static_cast<T>(rhs)); \
}
#endif//SKULLC_UTILITY_ENUM_HELPERS_HPP_

View File

@ -8,8 +8,6 @@
#ifndef SKULLC_UTILITY_FUNCTION_HPP_
#define SKULLC_UTILITY_FUNCTION_HPP_
#include <utility_assert.hpp>
namespace Utility
{
@ -51,7 +49,7 @@ public:
explicit Function(signature callable)
: callable_(callable)
{
SKULLC_ASSERT_DEBUG(callable_);
assert(callable_);
}
~Function() override
@ -83,7 +81,7 @@ public:
explicit FunctionOwned(source& src, signature callable)
: src_(&src), callable_(callable)
{
SKULLC_ASSERT_DEBUG(callable_);
assert(callable_);
}
~FunctionOwned() override

View File

@ -71,7 +71,6 @@ struct StaticPointer
SKULLC_ASSERT_DEBUG(initialized_);
return reinterpret_cast<const value_type*>(storage);
}
private:
bool initialized_ = false;
};