Skip to content
Open
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
8 changes: 5 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
Language: Cpp
BasedOnStyle: LLVM
IndentWidth: 2
---
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
Expand Down Expand Up @@ -89,11 +91,11 @@ IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
- Regex: '^"(beman|llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
- Regex: '^(<|"(catch2|gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
Expand Down
28 changes: 14 additions & 14 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp

{
"name": "Beman Project Generic Devcontainer",
"image": "ghcr.io/bemanproject/devcontainers-gcc:14",
"postCreateCommand": "pre-commit",
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools"
]
}
}
}
{
"name": "Beman Project Generic Devcontainer",
"image": "ghcr.io/bemanproject/devcontainers-gcc:14",
"postCreateCommand": "pre-commit",
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools"
]
}
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# Miscellaneous build and testing folders
build/
compile_commands.json

# Loose files
.DS_Store
19 changes: 14 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,39 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
exclude: ^\.clang-(format|tidy)$
- id: check-added-large-files

# Clang-format for C++
# This brings in a portable version of clang-format.
# See also: https://github.com/ssciwr/clang-format-wheel
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.8
rev: v21.1.6
hooks:
- id: clang-format
types_or: [c++, c]
types_or: [c++, c, json]

# # CMake linting and formatting
# - repo: https://github.com/BlankSpruce/gersemi
# rev: 0.23.1
# hooks:
# - id: gersemi
# name: CMake linting
# exclude: ^.*/tests/.*/data/ # Exclude test data directories

# Markdown linting
# Config file: .markdownlint.yaml
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.42.0
rev: v0.46.0
hooks:
- id: markdownlint

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
rev: v2.4.1
hooks:
- id: codespell
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
cmake_minimum_required(VERSION 3.28)
cmake_minimum_required(VERSION 3.28...4.2)

include(cmake/bootstrap_vcpkg.cmake)

Expand Down
18 changes: 12 additions & 6 deletions examples/cartesian_plane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import beman.bounds_test;

namespace bt = beman::bounds_test;

namespace {

template <typename T>
concept SignedNumber = std::is_arithmetic_v<T> && std::is_signed_v<T>;

Expand All @@ -28,22 +30,26 @@ constexpr auto try_reflect_y_axis(Point<T>& p) noexcept {
return bt::can_negate(p.x) ? std::optional<Point<T>>{std::in_place, static_cast<T>(-p.x), p.y} : std::nullopt;
}

} // namespace

int main() {
auto test_reflect = [&](auto& pt) {
std::cout << "Original: (" << pt.x << ", " << pt.y << ")\n";
if (auto r = try_reflect_x_axis(pt))
if (auto r = try_reflect_x_axis(pt)) {
std::cout << "\tRefleted across X: (" << r->x << ", " << r->y << ")\n";
else
} else {
std::cout << "\tRefelction across X would cause overflow\n";
}

if (auto r = try_reflect_y_axis(pt))
if (auto r = try_reflect_y_axis(pt)) {
std::cout << "\tRefleted across Y: (" << r->x << ", " << r->y << ")\n";
else
} else {
std::cout << "\tRefelction across Y would cause overflow\n";
}
};

Point<int> p{7, 15};
Point<int> p{.x = 7, .y = 15};
test_reflect(p);
Point<int> q{12, std::numeric_limits<int>::min()};
Point<int> q{.x = 12, .y = std::numeric_limits<int>::min()};
test_reflect(q);
}