Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/groups.dox
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@
* @defgroup util Utility
* @brief Helper functions, types, concepts, etc.
*/

/**
* @defgroup traits Traits & Concepts
* @brief Type trait and concept definitions.
*/
10 changes: 5 additions & 5 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ Command Result
Validates that the value is strictly greater than `lower_bound`.

```cpp
template <argon::util::c_arithmetic T>
template <argon::traits::c_arithmetic T>
argon::action::util::callable_type<argon::action_type::observe, T> gt(const T lower_bound) noexcept;
```

Expand All @@ -725,7 +725,7 @@ Command Result
Validates that the value is greater than or equal to `lower_bound`.

```cpp
template <argon::util::c_arithmetic T>
template <argon::traits::c_arithmetic T>
argon::action::util::callable_type<argon::action_type::observe, T> geq(const T lower_bound) noexcept;
```

Expand All @@ -734,7 +734,7 @@ Command Result
Validates that the value is strictly less than `upper_bound`.

```cpp
template <argon::util::c_arithmetic T>
template <argon::traits::c_arithmetic T>
argon::action::util::callable_type<argon::action_type::observe, T> lt(const T upper_bound) noexcept;
```

Expand All @@ -743,7 +743,7 @@ Command Result
Validates that the value is less than or equal to `upper_bound`.

```cpp
template <argon::util::c_arithmetic T>
template <argon::traits::c_arithmetic T>
argon::action::util::callable_type<argon::action_type::observe, T> leq(const T upper_bound) noexcept;
```

Expand All @@ -752,7 +752,7 @@ Command Result
Checks if the value is within the given interval. Bound inclusivity is customizable using template parameters.

```cpp
template <argon::util::c_arithmetic T, bool LeftInclusive = true, bool RightInclusive = true>
template <argon::traits::c_arithmetic T, bool LeftInclusive = true, bool RightInclusive = true>
argon::action::util::callable_type<argon::action_type::observe, T> within(
const T lower_bound, const T upper_bound
) noexcept;
Expand Down
12 changes: 6 additions & 6 deletions include/argon/action/predefined.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#pragma once

#include "argon/action/util/helpers.hpp"
#include "argon/action/util.hpp"
#include "argon/exceptions.hpp"

#include <filesystem>
Expand Down Expand Up @@ -54,7 +54,7 @@ inline util::callable_type<argon::action_type::observe, std::string> check_file_
* @tparam T The *arithmetic* value type.
* @param lower_bound The exclusive lower bound to validate against.
*/
template <argon::util::c_arithmetic T>
template <argon::traits::c_arithmetic T>
util::callable_type<argon::action_type::observe, T> gt(const T lower_bound) noexcept {
return [lower_bound](const T& value) {
if (not (value > lower_bound))
Expand All @@ -69,7 +69,7 @@ util::callable_type<argon::action_type::observe, T> gt(const T lower_bound) noex
* @tparam T The *arithmetic* value type.
* @param lower_bound The inclusive lower bound to validate against.
*/
template <argon::util::c_arithmetic T>
template <argon::traits::c_arithmetic T>
util::callable_type<argon::action_type::observe, T> geq(const T lower_bound) noexcept {
return [lower_bound](const T& value) {
if (! (value >= lower_bound))
Expand All @@ -84,7 +84,7 @@ util::callable_type<argon::action_type::observe, T> geq(const T lower_bound) noe
* @tparam T The *arithmetic* value type.
* @param lower_bound The exclusive upper bound to validate against.
*/
template <argon::util::c_arithmetic T>
template <argon::traits::c_arithmetic T>
util::callable_type<argon::action_type::observe, T> lt(const T upper_bound) noexcept {
return [upper_bound](const T& value) {
if (! (value < upper_bound))
Expand All @@ -99,7 +99,7 @@ util::callable_type<argon::action_type::observe, T> lt(const T upper_bound) noex
* @tparam T The *arithmetic* value type.
* @param lower_bound The inclusive upper bound to validate against.
*/
template <argon::util::c_arithmetic T>
template <argon::traits::c_arithmetic T>
util::callable_type<argon::action_type::observe, T> leq(const T upper_bound) noexcept {
return [upper_bound](const T& value) {
if (! (value <= upper_bound))
Expand All @@ -120,7 +120,7 @@ util::callable_type<argon::action_type::observe, T> leq(const T upper_bound) noe
* @param lower_bound The lower bound of the interval.
* @param upper_bound The upper bound of the interval.
*/
template <argon::util::c_arithmetic T, bool LeftInclusive = true, bool RightInclusive = true>
template <argon::traits::c_arithmetic T, bool LeftInclusive = true, bool RightInclusive = true>
util::callable_type<argon::action_type::observe, T> within(
const T lower_bound, const T upper_bound
) noexcept {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// Licensed under the MIT License. See the LICENSE file in the project root for full license information.

/**
* @file argon/action/util/concepts.hpp
* @brief Defines action-related concepts.
* @file argon/action/traits.hpp
* @brief Defines action-related traits and concepts.
*/

#pragma once
Expand All @@ -14,31 +14,31 @@
#include <utility>
#include <variant>

namespace argon::action::util {
namespace argon::traits {

/**
* @brief The concept is satisfied when `AS` is a valid *value* action action specifier.
* @tparam AS The action specifier type.
* @ingroup util
* @ingroup traits
*/
template <typename AS>
concept c_value_action_specifier =
argon::util::c_one_of<AS, action_type::observe, action_type::transform, action_type::modify>;
argon::traits::c_one_of<AS, action_type::observe, action_type::transform, action_type::modify>;

/**
* @brief The concept is satisfied when `AS` is a valid *on-flag* action action specifier.
* @tparam AS The action specifier type.
* @ingroup util
* @ingroup traits
*/
template <typename AS>
concept c_flag_action_specifier = argon::util::c_one_of<AS, action_type::on_flag>;
concept c_flag_action_specifier = argon::traits::c_one_of<AS, action_type::on_flag>;

/**
* @brief The concept is satisfied when `AS` is a valid action action specifier.
* @tparam AS The action specifier type.
* @ingroup util
* @ingroup traits
*/
template <typename AS>
concept c_action_specifier = c_value_action_specifier<AS> or std::same_as<AS, action_type::on_flag>;

} // namespace argon::action::util
} // namespace argon::traits
8 changes: 4 additions & 4 deletions include/argon/action/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#pragma once

#include "argon/util/concepts.hpp"
#include "argon/traits.hpp"

#include <functional>

Expand All @@ -22,7 +22,7 @@ namespace argon::action_type {
* performs some logic on it without modifying it.
*/
struct observe {
template <argon::util::c_argument_value_type T>
template <argon::traits::c_argument_value_type T>
using type = std::function<void(const T&)>;
};

Expand All @@ -33,7 +33,7 @@ struct observe {
* returns a new value with which the argument will be initialized.
*/
struct transform {
template <argon::util::c_argument_value_type T>
template <argon::traits::c_argument_value_type T>
using type = std::function<T(const T&)>;
};

Expand All @@ -44,7 +44,7 @@ struct transform {
* already initialized argument.
*/
struct modify {
template <argon::util::c_argument_value_type T>
template <argon::traits::c_argument_value_type T>
using type = std::function<void(T&)>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// Licensed under the MIT License. See the LICENSE file in the project root for full license information.

/**
* @file argon/action/util/helpers.hpp
* @file argon/action/util.hpp
* @brief Defines general action-related helper utility.
*/

#pragma once

#include "argon/action/util/concepts.hpp"
#include "argon/action/traits.hpp"

#include <utility>
#include <variant>
Expand All @@ -18,11 +18,11 @@ namespace argon::action::util {

/// @brief Template argument action callable type alias.
/// @ingroup util
template <c_value_action_specifier AS, argon::util::c_argument_value_type T>
template <traits::c_value_action_specifier AS, traits::c_argument_value_type T>
using callable_type = typename AS::template type<T>;

/// @brief Template argument action callabla variant type alias.
template <argon::util::c_argument_value_type T>
template <traits::c_argument_value_type T>
using value_action_variant_type = std::variant<
callable_type<action_type::observe, T>,
callable_type<action_type::transform, T>,
Expand All @@ -33,7 +33,7 @@ using value_action_variant_type = std::variant<
* @tparam T The argument's value type
* @ingroup util
*/
template <argon::util::c_argument_value_type T>
template <traits::c_argument_value_type T>
struct apply_visitor {
using value_type = T;

Expand Down
Loading
Loading