Skip to content

Commit 24dd769

Browse files
committed
wip: cfg refinement + cstm concept docs
1 parent 47d64f8 commit 24dd769

7 files changed

Lines changed: 96 additions & 8 deletions

File tree

docs/cpp-gl/concepts.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Concepts API Reference {: #concepts-api-reference }
2+
3+
This page serves as the central index for all C++20 concepts used across the library to enforce type safety and template constraints.
4+
5+
> [!IMPORTANT]
6+
> This page is maintained manually and separately from the auto-generated API reference as the [MkDoxy](https://github.com/JakubAndrysek/MkDoxy) tool does not currently support generating documentation for concepts.
7+
8+
---
9+
10+
## Graph Library (GL) Concepts
11+
12+
The Graph Library (GL) module relies on concepts to validate identifier types and property structures at compile time.
13+
14+
- **[GL Traits & Concepts Documentation](gl_traits.md)**: Full API reference for the GL module.
15+
- [`gl::traits::c_id_type`](gl_traits.md#gl-traits-c-id-type): Concept defining the requirements for an identifier type.

docs/cpp-gl/gl_traits.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# GL Traits & Concepts Documentation {: #gl-traits-concepts-documentation }
2+
3+
This page documents the C++20 concepts and type traits used to constrain templates across the GL library.
4+
5+
> [!IMPORTANT]
6+
> This page is maintained manually and separately from the auto-generated API reference as the [MkDoxy](https://github.com/JakubAndrysek/MkDoxy) tool does not currently support generating documentation for concepts.
7+
8+
---
9+
10+
## **gl::traits::c_id_type** {: #gl-traits-c-id-type }
11+
12+
**Module:** Part of the [GL-Traits](group__GL-Traits.md) group.
13+
14+
Concept defining the requirements for an identifier type.
15+
16+
### Detailed Description
17+
18+
Ensures that any custom ID type provided to the graph library is an unsigned integral type to guarantee safe indexing and representation.
19+
20+
### Template Parameters
21+
22+
| Parameter | Description |
23+
| :--- | :--- |
24+
| `T` | The type to evaluate against the concept. |
25+
26+
### Definition
27+
28+
```cpp
29+
template <typename T>
30+
concept c_id_type = std::unsigned_integral<T>;
31+
```

docs/groups.dox

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/// @defgroup GL-Algorithm Graph Algorithms
1717
/// @ingroup GL
1818
/// @brief Common graph algorithms and algorithm-related utility.
19+
/// @todo Refine description
1920
///
2021
/// Provides generic, highly customizable implementations of classic graph algorithms.
2122
/// This includes standard search templates (BFS, DFS, PFS), shortest path finders
@@ -44,6 +45,10 @@
4445
/// Encapsulates the `gl::traits` namespace. These components are used extensively throughout the
4546
/// library to constrain template parameters and interrogate types at compile time (e.g., deducing
4647
/// underlying vertex/edge types, querying graph directedness, or enforcing structural constraints).
48+
///
49+
/// @section concepts_link Detailed Concept Specifications
50+
/// For a detailed list of all GL module's concepts and their formal requirements, please refer to
51+
/// the [GL Traits & Concepts Documentation](gl_traits.md#gl-traits-concepts-documentation ) page.
4752

4853
/// @defgroup GL-Types Generic Types
4954
/// @ingroup GL

include/gl/types/core.hpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// This file is part of the CPP-GL project (https://github.com/SpectraL519/cpp-gl).
33
// Licensed under the MIT License. See the LICENSE file in the project root for full license information.
44

5+
/// @file gl/types/core.hpp
6+
/// @brief Core type definitions, traits, and utilities for the GL library.
7+
58
#pragma once
69

710
#include "gl/attributes/force_inline.hpp"
@@ -14,24 +17,58 @@
1417

1518
namespace gl {
1619

20+
/// @ingroup GL GL-Core
21+
/// @brief Type alias for the standard size type used throughout the library.
22+
///
23+
/// Used primarily for indices, counts, and sizes of graph components.
1724
using size_type = std::size_t;
25+
26+
/// @ingroup GL GL-Core
27+
/// @brief The default unsigned integer type used for vertex and edge identifiers.
1828
using default_id_type = std::uint32_t;
1929

30+
/// @namespace gl::traits
31+
/// @brief Contains C++20 concepts and type traits used to constrain library templates.
2032
namespace traits {
2133

34+
/// @ingroup GL GL-Traits
35+
/// @brief Concept defining the requirements for an identifier type.
36+
///
37+
/// Ensures that any custom ID type provided to the graph library is an
38+
/// unsigned integral type to guarantee safe indexing and representation.
39+
///
40+
/// @tparam T The type to evaluate against the concept.
2241
template <typename T>
2342
concept c_id_type = std::unsigned_integral<T>;
2443

2544
} // namespace traits
2645

46+
/// @ingroup GL GL-Util
47+
/// @brief Converts a valid identifier to a standard size type (index).
48+
///
49+
/// Provides a safe, explicit cast from any unsigned integral ID type
50+
/// into a `size_type`, commonly used for array/vector lookups.
51+
///
52+
/// @param id The identifier to convert.
53+
/// @return The identifier statically cast to `size_type`.
2754
[[nodiscard]] gl_attr_force_inline constexpr size_type to_idx(traits::c_id_type auto id) noexcept {
2855
return static_cast<size_type>(id);
2956
}
3057

58+
/// @ingroup GL GL-Util
59+
/// @brief Converts an integral value to a standard pointer difference type.
60+
///
61+
/// Useful for safe pointer arithmetic and offset calculations within graph data structures.
62+
///
63+
/// @param i The integral value to convert.
64+
/// @return The value statically cast to `std::ptrdiff_t`.
3165
[[nodiscard]] gl_attr_force_inline constexpr std::ptrdiff_t to_diff(std::integral auto i) noexcept {
3266
return static_cast<std::ptrdiff_t>(i);
3367
}
3468

69+
/// @ingroup GL GL-Types
70+
/// @brief A type alias for a `std::pair` where both elements are of the exact same type.
71+
/// @tparam `T` The type of both the `first` and `second` elements in the pair.
3572
template <typename T>
3673
using homogeneous_pair = std::pair<T, T>;
3774

include/gl/types/properties.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace gl {
1515

16+
/// @brief An empty properties type.
1617
struct empty_properties {};
1718

1819
struct empty_properties_map {};

include/gl/vertex_descriptor.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This file is part of the CPP-GL project (https://github.com/SpectraL519/cpp-gl).
33
// Licensed under the MIT License. See the LICENSE file in the project root for full license information.
44

5-
/// @file vertex_descriptor.hpp
5+
/// @file gl/vertex_descriptor.hpp
66
/// @brief Defines the vertex_descriptor class, a lightweight wrapper for vertex representations in graphs.
77

88
#pragma once
@@ -49,17 +49,16 @@ namespace gl {
4949
///
5050
/// 2\. Use the arrow operator to access/modify custom property fields
5151
///
52-
/// @tparam Properties The type of property data attached to the vertex. Defaults to `empty_properties`.
53-
/// Must satisfy the @ref gl::traits::c_properites "c_properties" trait.
54-
/// @tparam IdType The underlying integer type used for the vertex ID. Defaults to `default_id_type`.
55-
/// Must satisfy the @ref gl::traits::c_id_type "c_id_type" trait.
52+
/// ### Template Parameters
53+
/// | Parameter | Description | Default | Constraint |
54+
/// | :--------- | :--- | :--- | :--- |
55+
/// | Properties | The type of property data attached to the vertex. | @ref gl::empty_properties "empty_properties" | @ref gl::traits::c_properties "c_properties" |
56+
/// | IdType | The underlying integer type used for the vertex ID. | @ref gl::default_id_type "default_id_type" | [c_id_type](gl_traits.md#gl-traits-c-id-type) |
5657
template <
5758
traits::c_properties Properties = empty_properties,
5859
traits::c_id_type IdType = default_id_type>
5960
class vertex_descriptor final {
6061
public:
61-
/// @brief Type alias for the vertex_descriptor itself.
62-
using type = std::type_identity_t<vertex_descriptor<Properties, IdType>>;
6362
/// @brief The vertex identifier type
6463
using id_type = IdType;
6564
/// @brief The type of properties associated with the vertex.

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ nav:
2222
- Namespaces: cpp-gl/namespaces.md
2323
- Classes & Structs: cpp-gl/annotated.md
2424
- Class Hierarchy: cpp-gl/hierarchy.md
25-
# - Concepts: cpp-gl/concepts.md
25+
- Concepts: cpp-gl/concepts.md
2626
- Files: cpp-gl/files.md
2727
- Todo List: cpp-gl/todo.md
2828
# - Bug List: cpp-gl/bug.md

0 commit comments

Comments
 (0)