Skip to content

Commit 68e7a97

Browse files
authored
Merge pull request #124 from steve-downey/format_kind
`format_kind` support for optional, now that compilers are implementing it.
2 parents 2148253 + 647d3df commit 68e7a97

File tree

6 files changed

+37
-4
lines changed

6 files changed

+37
-4
lines changed

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# cmake-format: on
66

77
INSTALL_PREFIX?=.install/
8-
PROJECT?=$(shell basename $(CURDIR))
98
BUILD_DIR?=.build
109
DEST?=$(INSTALL_PREFIX)
1110
CMAKE_FLAGS?=
@@ -62,9 +61,11 @@ $(_build_path)/CMakeCache.txt: | $(_build_path) .gitmodules
6261

6362
TARGET:=all
6463
compile: $(_build_path)/CMakeCache.txt ## Compile the project
65-
cmake --build $(_build_path) --config $(CONFIG) --target all_verify_interface_header_sets -- -k 0
6664
cmake --build $(_build_path) --config $(CONFIG) --target all -- -k 0
6765

66+
compile-headers: $(_build_path)/CMakeCache.txt ## Compile the headers
67+
cmake --build $(_build_path) --config $(CONFIG) --target all_verify_interface_header_sets -- -k 0
68+
6869
install: $(_build_path)/CMakeCache.txt compile ## Install the project
6970
cmake --install $(_build_path) --config $(CONFIG) --component beman_optional_development --verbose
7071

@@ -98,7 +99,7 @@ papers:
9899
cmake --build $(_build_path) --config $(CONFIG) --target $@ -- -k 0
99100

100101
PYEXECPATH ?= $(shell which python3.12 || which python3.11 || which python3.10 || which python3.9 || which python3.8 || which python3.7 || which python3)
101-
PYTHON ?= $(shell basename $(PYEXECPATH))
102+
PYTHON ?= $(notdir $(PYEXECPATH))
102103
VENV := .venv
103104
ACTIVATE := . $(VENV)/bin/activate &&
104105
PYEXEC := $(ACTIVATE) $(PYTHON)

etc/gcc-15-toolchain.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/gcc-flags.cmake")
44

55
set(CMAKE_C_COMPILER gcc-15)
66
set(CMAKE_CXX_COMPILER g++-15)
7+
set(GCOV_EXECUTABLE "gcov-15" CACHE STRING "GCOV executable" FORCE)
78

89
set(CMAKE_CXX_FLAGS_ASAN
910
"${CMAKE_CXX_FLAGS_ASAN} -Wno-maybe-uninitialized"

etc/gcc-16-toolchain.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
include_guard(GLOBAL)
2+
3+
include("${CMAKE_CURRENT_LIST_DIR}/gcc-flags.cmake")
4+
5+
set(CMAKE_C_COMPILER gcc-16)
6+
set(CMAKE_CXX_COMPILER g++-16)
7+
set(GCOV_EXECUTABLE "gcov-16" CACHE STRING "GCOV executable" FORCE)
8+
9+
set(CMAKE_CXX_FLAGS_ASAN
10+
"${CMAKE_CXX_FLAGS_ASAN} -Wno-maybe-uninitialized"
11+
CACHE STRING
12+
"C++ ASAN Flags"
13+
FORCE
14+
)

etc/gcc-flags.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ include_guard(GLOBAL)
22

33
set(CMAKE_CXX_STANDARD 23)
44

5-
set(CMAKE_CXX_FLAGS "-std=c++23 -Wall -Wextra " CACHE STRING "CXX_FLAGS" FORCE)
5+
set(CMAKE_CXX_FLAGS "-Wall -Wextra " CACHE STRING "CXX_FLAGS" FORCE)
66

77
set(CMAKE_CXX_FLAGS_DEBUG
88
"-O0 -fno-inline -g3"

include/beman/optional/optional.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#ifndef BEMAN_OPTIONAL_OPTIONAL_HPP
55
#define BEMAN_OPTIONAL_OPTIONAL_HPP
66

7+
#include <version>
78
#include <compare>
89
#include <concepts>
910
#if defined(__cpp_lib_format_ranges)

tests/beman/optional/optional_range_support.t.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,22 @@ TEST(RangeSupportTest, EndOnNonEmptyOptional) {
231231
lambda();
232232
}
233233

234+
#if ((__GNUC__ >= 15) && (__GNUC_MINOR__ >= 1) && (__GNUC_PATCHLEVEL__ >= 1)) || ((__GNUC__ >= 16))
235+
static_assert(std::format_kind<beman::optional::optional<int>> == std::range_format::disabled);
236+
#endif
237+
238+
#if defined(__cpp_lib_format_ranges)
239+
static_assert(std::format_kind<beman::optional::optional<int>> == std::range_format::disabled);
240+
static_assert(std::format_kind<beman::optional::optional<int&>> == std::range_format::disabled);
241+
static_assert(std::format_kind<beman::optional::optional<int*>> == std::range_format::disabled);
242+
static_assert(std::format_kind<beman::optional::optional<empty>> == std::range_format::disabled);
243+
static_assert(std::format_kind<beman::optional::optional<empty&>> == std::range_format::disabled);
244+
static_assert(std::format_kind<beman::optional::optional<base>> == std::range_format::disabled);
245+
static_assert(std::format_kind<beman::optional::optional<base&>> == std::range_format::disabled);
246+
static_assert(std::format_kind<beman::optional::optional<derived>> == std::range_format::disabled);
247+
static_assert(std::format_kind<beman::optional::optional<derived&>> == std::range_format::disabled);
248+
#endif
249+
234250
TEST(RangeSupportTest, FormatOptionalIsStillDisabled) {
235251
// TODO: Always enable when all major compilers implement P2585R1: "Improve default container formatting".
236252
#if defined(__cpp_lib_format_ranges)

0 commit comments

Comments
 (0)