Skip to content
Closed
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: 4 additions & 4 deletions .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
steps:
- uses: actions/checkout@v6

- name: Install clang-format
- name: Install clang-format-21
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh 19
sudo apt-get install -y clang-format-19
sudo ./llvm.sh 21
sudo apt-get install -y clang-format-21

- name: Install Cabin
run: |
Expand All @@ -34,7 +34,7 @@ jobs:
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
cabin fmt --check --verbose
env:
CABIN_FMT: clang-format-19
CABIN_FMT: clang-format-21

lint:
runs-on: ubuntu-24.04
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/document-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
compiler:
- cc: clang
cxx: clang++
ver: 17
ver: 21
- cc: gcc
cxx: g++
ver: 13
ver: 14
env:
CC: ${{ matrix.compiler.cc }}-${{ matrix.compiler.ver }}
CXX: ${{ matrix.compiler.cxx }}-${{ matrix.compiler.ver }}
Expand Down
45 changes: 10 additions & 35 deletions .github/workflows/full-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,15 @@ jobs:
compiler:
- cc: clang
cxx: clang++
ver: 15
os: ubuntu-22.04
- cc: clang
cxx: clang++
ver: 16
os: ubuntu-22.04
- cc: clang
cxx: clang++
ver: 17
ver: 19
os: ubuntu-24.04
- cc: clang
cxx: clang++
ver: 18
ver: 20
os: ubuntu-24.04
- cc: clang
cxx: clang++
ver: 19
os: ubuntu-24.04
- cc: gcc
cxx: g++
ver: 11
os: ubuntu-22.04
- cc: gcc
cxx: g++
ver: 12
os: ubuntu-24.04
- cc: gcc
cxx: g++
ver: 13
ver: 21
os: ubuntu-24.04
- cc: gcc
cxx: g++
Expand All @@ -61,21 +41,16 @@ jobs:
sudo apt-get -qq update
sudo apt-get install -y -qq pkg-config cmake

- name: Install Clang
- name: Install Clang ${{ matrix.compiler.ver }}
if: startsWith(matrix.compiler.cxx, 'clang')
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh ${{ matrix.compiler.ver }}

- name: Install GCC
if: matrix.compiler.cxx == 'g++' && matrix.compiler.ver == 14
run: sudo apt update && sudo apt install -y gcc-14

- name: Install fmt
run: |
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew install fmt
- name: Install GCC ${{ matrix.compiler.ver }}
if: matrix.compiler.cxx == 'g++'
run: sudo apt update && sudo apt install -y gcc-${{ matrix.compiler.ver }}

- name: Build and test
run: |
Expand All @@ -90,14 +65,14 @@ jobs:
strategy:
fail-fast: false
matrix:
osver: [13, 14, 15]
osver: [15, 26]
steps:
- uses: actions/checkout@v6
with:
submodules: true

- name: Install CMake & fmt
run: brew install pkg-config cmake fmt
- name: Install CMake
run: brew install pkg-config cmake

- name: Build and test
run: |
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.20)
## Set our project name
project(mitama-cpp-result
VERSION 11.0.0
Expand All @@ -11,7 +11,7 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
add_library(${PROJECT_NAME} INTERFACE)
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_20)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_23)
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# mitama-cpp-result

**mitama-cpp-result** is the C++20 libraries for error handling without exceptions.
**mitama-cpp-result** is the C++23 libraries for error handling without exceptions.

**mitama-cpp-result** provides `result<T, E>`, `maybe<T>`, and associated monadic functions
(like [Result](https://doc.rust-lang.org/std/result/enum.Result.html)
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Introduction

`Mitama.Result` is a header only C++20 library for error handling.
`Mitama.Result` is a header only C++23 library for error handling.


## Installation


### Dependencies

* fmt: 9.0.0 or higher
* No external dependencies


### Supported OS / Compiler / Language Standard
Expand All @@ -24,7 +24,7 @@
- Latest preview version of MSVC only

- Language Standards
- C++20
- C++23
- (MSVC: only support `/std:c++latest`)


Expand Down
2 changes: 1 addition & 1 deletion docs/docs/thiserror/thiserror.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct data_store_error : mitama::thiserror::derive_error {
```

The first template argument of `mitama::thiserror::error` is embedded with a format string.
The format string should be a string compliant with [**{fmt}**](https://github.com/fmtlib/fmt), check the documentation if you need it.
The format string follows the `std::format` grammar.
The second template argument onwards is a list of formattable arguments.

`mitama::thiserror::error` inherits from `anyhow::error`, so it can be used together with anyhow.
Expand Down
2 changes: 1 addition & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
site_name: Mitama.Result User Manual
site_url: https://loligothick.github.io/mitama-cpp-result/
site_description: Mitama.Result C++20 Library
site_description: Mitama.Result C++23 Library
site_author: mitama

# Repository
Expand Down
20 changes: 14 additions & 6 deletions include/mitama/anyhow/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <mitama/mitamagic/format.hpp>
#include <mitama/result/factory/failure.hpp>

#include <fmt/core.h>
#include <memory>
#include <sstream>
#include <string>
Expand Down Expand Up @@ -158,11 +157,11 @@ anyhow(E&& err) -> std::shared_ptr<mitama::anyhow::error>
);
}
template <class... E>
requires(fmt::is_formattable<E>::value && ...)
requires(std::formattable<E, char> && ...)
inline auto
anyhow(fmt::format_string<E...> f, E&&... args)
anyhow(std::format_string<E...> f, E&&... args)
{
return anyhow(fmt::format(f, std::forward<E>(args)...));
return anyhow(std::format(f, std::forward<E>(args)...));
}

inline std::ostream&
Expand All @@ -184,9 +183,18 @@ failure(Args&&... args) -> mitama::failure_t<std::shared_ptr<Err>>
} // namespace mitama::anyhow

template <>
struct fmt::formatter<std::shared_ptr<mitama::anyhow::error>>
: ostream_formatter
struct std::formatter<std::shared_ptr<mitama::anyhow::error>, char>
: std::formatter<std::string, char>
{
template <class FormatContext>
auto format(
const std::shared_ptr<mitama::anyhow::error>& err, FormatContext& ctx
) const
{
return std::formatter<std::string, char>::format(
err ? err->what() : std::string{}, ctx
);
}
};

#define MITAMA_BAIL(...) \
Expand Down
28 changes: 21 additions & 7 deletions include/mitama/maybe/factory/just_nothing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <mitama/result/detail/meta.hpp>

#include <iostream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
Expand Down Expand Up @@ -117,7 +118,8 @@ class [[nodiscard]] just_t<T>
template <class U>
requires not_self<std::decay_t<U>>::value
&& std::is_constructible_v<T, U> && (!std::is_convertible_v<U, T>)
explicit constexpr just_t(U&& u
explicit constexpr just_t(
U&& u
) noexcept(std::is_nothrow_constructible_v<T, U>)
: x(std::forward<U>(u))
{
Expand All @@ -126,7 +128,8 @@ class [[nodiscard]] just_t<T>
template <typename U>
requires(!std::is_same_v<T, U>) && std::is_constructible_v<T, const U&>
&& std::is_convertible_v<const U&, T>
constexpr just_t(const just_t<U>& t
constexpr just_t(
const just_t<U>& t
) noexcept(std::is_nothrow_constructible_v<T, U>)
: x(t.get())
{
Expand All @@ -135,7 +138,8 @@ class [[nodiscard]] just_t<T>
template <typename U>
requires(!std::is_same_v<T, U>) && std::is_constructible_v<T, const U&>
&& (!std::is_convertible_v<const U&, T>)
explicit constexpr just_t(const just_t<U>& t
explicit constexpr just_t(
const just_t<U>& t
) noexcept(std::is_nothrow_constructible_v<T, U>)
: x(t.get())
{
Expand All @@ -144,7 +148,8 @@ class [[nodiscard]] just_t<T>
template <typename U>
requires(!std::is_same_v<T, U>)
&& std::is_constructible_v<T, U&&> && std::is_convertible_v<U&&, T>
constexpr just_t(just_t<U>&& t
constexpr just_t(
just_t<U>&& t
) noexcept(std::is_nothrow_constructible_v<T, U>)
: x(std::move(t.get()))
{
Expand All @@ -153,7 +158,8 @@ class [[nodiscard]] just_t<T>
template <typename U>
requires(!std::is_same_v<T, U>) && std::is_constructible_v<T, U&&>
&& (!std::is_convertible_v<U &&, T>)
explicit constexpr just_t(just_t<U>&& t
explicit constexpr just_t(
just_t<U>&& t
) noexcept(std::is_nothrow_constructible_v<T, U>)
: x(std::move(t.get()))
{
Expand Down Expand Up @@ -625,7 +631,7 @@ template <class T>
inline std::ostream&
operator<<(std::ostream& os, const just_t<T>& j)
{
return os << fmt::format("just({})", quote_str(j.get()));
return os << std::format("just({})", quote_str(j.get()));
}

template <class Target = void, class... Types>
Expand Down Expand Up @@ -680,6 +686,14 @@ class [[nodiscard]] just_t<_just_detail::forward_mode<T>, Args...>
} // namespace mitama

template <class T>
struct fmt::formatter<mitama::just_t<T>> : ostream_formatter
struct std::formatter<mitama::just_t<T>, char>
: std::formatter<std::string, char>
{
template <class FormatContext>
auto format(const mitama::just_t<T>& value, FormatContext& ctx) const
{
return std::formatter<std::string, char>::format(
std::format("just({})", quote_str(value.get())), ctx
);
}
};
Loading
Loading