Skip to content

Commit

Permalink
chore: remove logical traits backport
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
The project requires C++17 as it is widely available in compilers now.
Logical traits such as conjunction, disjunction and negation are available
from the <type_traits> standard include.
  • Loading branch information
abdes committed Dec 7, 2021
1 parent 5000c96 commit 5ed0fe6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 228 deletions.
5 changes: 3 additions & 2 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ asap_add_library(
"include/common/compilers.h"
"include/common/singleton.h"
"include/common/flag_ops.h"
# traits module
"include/common/traits/logical.h"
# contract module
"include/contract/contract.h"
"include/contract/ut/gtest.h"
Expand All @@ -76,6 +74,9 @@ target_include_directories(
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

target_compile_features(${MODULE_TARGET_NAME} PUBLIC cxx_std_17)


# Add support for (optional) code quality tools
asap_add_sanitizers(${MODULE_TARGET_NAME})

Expand Down
27 changes: 12 additions & 15 deletions common/include/common/flag_ops.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
/* SPDX-License-Identifier: BSD-3-Clause */

// Copyright The Authors 2018.
// Distributed under the 3-Clause BSD License.
// (See accompanying file LICENSE or copy at
// https://opensource.org/licenses/BSD-3-Clause)

#pragma once

#include <common/traits/logical.h>
#include <type_traits>

namespace asap {

/*!
* @brief Set bits in a mask based on the bits set in flags.
*
* @param[in,out] mask the bitset mask to be changed.
* @param[in] flags the flags to set in the mask. May contain one or more
* bits to set.
* @param[in] flags the flags to set in the mask. May contain one or more bits to set.
*/
template <typename T,
typename std::enable_if<asap::disjunction<std::is_arithmetic<T>, std::is_enum<T>>::value>::type
typename std::enable_if<std::disjunction<std::is_arithmetic<T>, std::is_enum<T>>::value>::type
* = nullptr>
void FlagSet(T &mask, T flags) {
mask |= flags;
Expand All @@ -27,26 +28,23 @@ void FlagSet(T &mask, T flags) {
* @brief Clear bits in a mask based on the bits set in flags.
*
* @param[in,out] mask the bitset mask to be changed.
* @param[in] flags the flags to clear in the mask. May contain one or more
* bits to clear.
* @param[in] flags the flags to clear in the mask. May contain one or more bits to clear.
*/
template <typename T,
typename std::enable_if<asap::disjunction<std::is_arithmetic<T>, std::is_enum<T>>::value>::type
typename std::enable_if<std::disjunction<std::is_arithmetic<T>, std::is_enum<T>>::value>::type
* = nullptr>
void FlagClear(T &mask, T flags) {
mask &= ~flags;
}

/*!
* @brief Flip bits ('0' to '1' and '1' to '0') in a mask based on the bits set
* in flags.
* @brief Flip bits ('0' to '1' and '1' to '0') in a mask based on the bits set in flags.
*
* @param[in,out] mask the bitset mask to be changed.
* @param[in] flags the flags to flip in the mask. May contain one or more
* bits to set.
* @param[in] flags the flags to flip in the mask. May contain one or more bits to set.
*/
template <typename T,
typename std::enable_if<asap::disjunction<std::is_arithmetic<T>, std::is_enum<T>>::value>::type
typename std::enable_if<std::disjunction<std::is_arithmetic<T>, std::is_enum<T>>::value>::type
* = nullptr>
void FlagFlip(T &mask, T flags) {
mask ^= flags;
Expand All @@ -56,13 +54,12 @@ void FlagFlip(T &mask, T flags) {
* @brief Check if the bits set in `flags` are also set in `mask`.
*
* @param[in] mask the bitset mask to be tested.
* @param[in] flags the flags to check in the mask. May contain one or more
* bits to set.
* @param[in] flags the flags to check in the mask. May contain one or more bits to set.
*
* @return \b true if the flags are set in mask; otherwise \b false;
*/
template <typename T,
typename std::enable_if<asap::disjunction<std::is_arithmetic<T>, std::is_enum<T>>::value>::type
typename std::enable_if<std::disjunction<std::is_arithmetic<T>, std::is_enum<T>>::value>::type
* = nullptr>
auto FlagTest(T mask, T flags) -> bool {
return (mask & flags) == flags;
Expand Down
47 changes: 0 additions & 47 deletions common/include/common/traits/logical.h

This file was deleted.

1 change: 0 additions & 1 deletion common/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ asap_add_test(
UNIT_TEST
VALGRIND_MEMCHECK
SRCS
"traits_logical_test.cpp"
"flag_ops_test.cpp"
"main.cpp"
LINK
Expand Down
163 changes: 0 additions & 163 deletions common/test/traits_logical_test.cpp

This file was deleted.

0 comments on commit 5ed0fe6

Please sign in to comment.