Skip to content

Commit

Permalink
Rename "flags" design to "enum"
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickroberts committed Feb 8, 2025
1 parent bf85d28 commit da37e7b
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
matrix:
design:
- description: Enum Flags
arg: -DBEMAN_ANY_VIEW_DESIGN=FLAGS
arg: -DBEMAN_ANY_VIEW_DESIGN=ENUM
- description: Range Traits
arg: -DBEMAN_ANY_VIEW_DESIGN=TRAITS
- description: Named Template Arguments
Expand Down
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ option(

# [CPP.NO_FLAG_FORKING]
set(BEMAN_ANY_VIEW_DESIGN
"FLAGS"
"ENUM"
CACHE STRING
"Enable alternative design for any_view_options. Default: FLAGS. Values: { FLAGS, TRAITS, NAMED }."
"Enable alternative design for any_view_options. Default: ENUM. Values: { ENUM, TRAITS, NAMED }."
)

set(BEMAN_ANY_VIEW_OPTION
Expand All @@ -28,22 +28,22 @@ set(BEMAN_ANY_VIEW_OPTION
"Enable opt-in option for any_view. Default: COPYABLE. Values: { COPYABLE, MOVE_ONLY }."
)

set(BEMAN_ANY_VIEW_USE_FLAGS OFF)
set(BEMAN_ANY_VIEW_USE_ENUM OFF)
set(BEMAN_ANY_VIEW_USE_TRAITS OFF)
set(BEMAN_ANY_VIEW_USE_NAMED OFF)
set(BEMAN_ANY_VIEW_USE_COPYABLE OFF)
set(BEMAN_ANY_VIEW_USE_MOVE_ONLY OFF)

if(BEMAN_ANY_VIEW_DESIGN STREQUAL "FLAGS")
set(BEMAN_ANY_VIEW_USE_FLAGS ON)
if(BEMAN_ANY_VIEW_DESIGN STREQUAL "ENUM")
set(BEMAN_ANY_VIEW_USE_ENUM ON)
elseif(BEMAN_ANY_VIEW_DESIGN STREQUAL "TRAITS")
set(BEMAN_ANY_VIEW_USE_TRAITS ON)
elseif(BEMAN_ANY_VIEW_DESIGN STREQUAL "NAMED")
set(BEMAN_ANY_VIEW_USE_NAMED ON)
else()
message(
FATAL_ERROR
"BEMAN_ANY_VIEW_DESIGN must be one of { FLAGS, TRAITS, NAMED }; got ${BEMAN_ANY_VIEW_DESIGN}"
"BEMAN_ANY_VIEW_DESIGN must be one of { ENUM, TRAITS, NAMED }; got ${BEMAN_ANY_VIEW_DESIGN}"
)
endif()

Expand Down
6 changes: 3 additions & 3 deletions include/beman/any_view/any_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <beman/any_view/detail/view_adaptor.hpp>
#include <beman/any_view/detail/view_interface.hpp>

#if BEMAN_ANY_VIEW_USE_FLAGS()
#if BEMAN_ANY_VIEW_USE_ENUM()

#include <beman/any_view/detail/type_traits.hpp>
#include <beman/any_view/any_view_options.hpp>
Expand All @@ -37,7 +37,7 @@ concept viewable_range_compatible_with = not std::same_as<std::remove_cvref_t<Ra

} // namespace detail

#if BEMAN_ANY_VIEW_USE_FLAGS()
#if BEMAN_ANY_VIEW_USE_ENUM()

template <class ElementT,
any_view_options OptionsV = any_view_options::input,
Expand Down Expand Up @@ -226,7 +226,7 @@ class any_view : public std::ranges::view_interface<any_view<ElementT, OptionsV>

} // namespace beman::any_view

#if BEMAN_ANY_VIEW_USE_FLAGS()
#if BEMAN_ANY_VIEW_USE_ENUM()

template <class ElementT, auto OptionsV, class RefT, class RValueRefT, class DiffT>
inline constexpr bool
Expand Down
4 changes: 2 additions & 2 deletions include/beman/any_view/any_view_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <beman/any_view/config.hpp>

#if BEMAN_ANY_VIEW_USE_FLAGS()
#if BEMAN_ANY_VIEW_USE_ENUM()

#include <iterator>

Expand All @@ -19,7 +19,7 @@

namespace beman::any_view {

#if BEMAN_ANY_VIEW_USE_FLAGS()
#if BEMAN_ANY_VIEW_USE_ENUM()

enum class any_view_options {
input = 0b0000000,
Expand Down
2 changes: 1 addition & 1 deletion include/beman/any_view/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef BEMAN_ANY_VIEW_CONFIG_HPP
#define BEMAN_ANY_VIEW_CONFIG_HPP

#cmakedefine01 BEMAN_ANY_VIEW_USE_FLAGS()
#cmakedefine01 BEMAN_ANY_VIEW_USE_ENUM()
#cmakedefine01 BEMAN_ANY_VIEW_USE_TRAITS()
#cmakedefine01 BEMAN_ANY_VIEW_USE_NAMED()

Expand Down
2 changes: 1 addition & 1 deletion tests/beman/any_view/options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <beman/any_view/config.hpp>

#if BEMAN_ANY_VIEW_USE_FLAGS()
#if BEMAN_ANY_VIEW_USE_ENUM()

#include <beman/any_view/any_view_options.hpp>

Expand Down
2 changes: 1 addition & 1 deletion tests/beman/any_view/sfinae.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct traits : BaseTraitsT {
};

TEST(SfinaeTest, vector_of_bool) {
#if BEMAN_ANY_VIEW_USE_FLAGS()
#if BEMAN_ANY_VIEW_USE_ENUM()
static_assert(std::constructible_from<any_view<bool, random_access_options, bool>, std::vector<bool>>);
static_assert(std::constructible_from<any_view<bool, sized_options, bool>, std::vector<bool>>);
static_assert(not std::constructible_from<any_view<bool, borrowed_options, bool>, std::vector<bool>>);
Expand Down
12 changes: 6 additions & 6 deletions tests/beman/any_view/type_traits.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TEST(TypeTraitsTest, value_type) {
static_assert(std::same_as<range_value_t<any_view<const value>>, value>);
}

#if BEMAN_ANY_VIEW_USE_FLAGS()
#if BEMAN_ANY_VIEW_USE_ENUM()

using enum beman::any_view::any_view_options;

Expand All @@ -44,7 +44,7 @@ TEST(TypeTraitsTest, reference_type) {
static_assert(std::same_as<range_reference_t<any_view<value>>, value&>);
static_assert(std::same_as<range_reference_t<any_view<const value>>, const value&>);

#if BEMAN_ANY_VIEW_USE_FLAGS()
#if BEMAN_ANY_VIEW_USE_ENUM()
static_assert(std::same_as<range_reference_t<any_view<value, input, value>>, value>);
static_assert(std::same_as<range_reference_t<any_view<value, input, lvalue>>, lvalue>);
#elif BEMAN_ANY_VIEW_USE_TRAITS()
Expand All @@ -70,7 +70,7 @@ TEST(TypeTraitsTest, rvalue_reference_type) {
static_assert(std::same_as<range_rvalue_reference_t<any_view<value>>, value&&>);
static_assert(std::same_as<range_rvalue_reference_t<any_view<const value>>, const value&&>);

#if BEMAN_ANY_VIEW_USE_FLAGS()
#if BEMAN_ANY_VIEW_USE_ENUM()
static_assert(std::same_as<range_rvalue_reference_t<any_view<value, input, value>>, value>);
static_assert(std::same_as<range_rvalue_reference_t<any_view<value, input, lvalue>>, lvalue>);
static_assert(std::same_as<range_rvalue_reference_t<any_view<value, input, lvalue, rvalue>>, rvalue>);
Expand Down Expand Up @@ -101,7 +101,7 @@ TEST(TypeTraitsTest, difference_type) {

static_assert(std::same_as<range_difference_t<any_view<value>>, std::ptrdiff_t>);

#if BEMAN_ANY_VIEW_USE_FLAGS()
#if BEMAN_ANY_VIEW_USE_ENUM()
static_assert(std::same_as<range_difference_t<any_view<value, input, lvalue, rvalue, short>>, short>);
#elif BEMAN_ANY_VIEW_USE_TRAITS()
static_assert(std::same_as<range_difference_t<any_view<value, difference_traits>>, short>);
Expand All @@ -128,7 +128,7 @@ struct sized_difference_traits : sized_traits {
TEST(TypeTraitsTest, size_type) {
using std::ranges::range_size_t;

#if BEMAN_ANY_VIEW_USE_FLAGS()
#if BEMAN_ANY_VIEW_USE_ENUM()
static_assert(std::same_as<range_size_t<any_view<value, input | sized>>, std::size_t>);
static_assert(std::same_as<range_size_t<any_view<value, input | sized, value&, value&&, short>>, unsigned short>);
#elif BEMAN_ANY_VIEW_USE_TRAITS()
Expand Down Expand Up @@ -159,7 +159,7 @@ TEST(TypeTraitsTest, borrowed_iterator_type) {

static_assert(std::same_as<borrowed_iterator_t<any_view<value>>, std::ranges::dangling>);

#if BEMAN_ANY_VIEW_USE_FLAGS()
#if BEMAN_ANY_VIEW_USE_ENUM()
static_assert(std::same_as<borrowed_iterator_t<any_view<value, input | borrowed>>,
iterator_t<any_view<value, input | borrowed>>>);
#elif BEMAN_ANY_VIEW_USE_TRAITS()
Expand Down

0 comments on commit da37e7b

Please sign in to comment.