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
15 changes: 13 additions & 2 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
DEBIAN_FRONTEND: noninteractive
CMAKE_GENERATOR: Ninja
DEFAULT_CXX_STANDARD: 20
DEFAULT_LLVM_VERSION: 20
DEFAULT_LLVM_VERSION: 21
DEFAULT_GCC_VERSION: 14
MULL_LLVM_VERSION: 18
MULL_VERSION: 0.26.1
Expand All @@ -30,7 +30,7 @@ jobs:
fail-fast: false
matrix:
compiler: [clang, gcc]
version: [12, 13, 14, 16, 17, 18, 19, 20]
version: [12, 13, 14, 16, 17, 18, 19, 20, 21]
cxx_standard: [17, 20]
stdlib: [libstdc++, libc++]
build_type: [Debug]
Expand All @@ -39,6 +39,15 @@ jobs:
cc: "clang"
cxx: "clang++"
cxx_flags: "-stdlib=libstdc++"
- version: 21
compiler: clang
install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 21
toolchain_root: "/usr/lib/llvm-21"
- version: 21
compiler: clang
stdlib: libc++
install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 21 && sudo apt install -y libc++-21-dev libc++abi-21-dev
cxx_flags: "-stdlib=libc++"
- version: 20
compiler: clang
install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 20
Expand Down Expand Up @@ -104,6 +113,8 @@ jobs:
cxx: "g++-12"
cxx_flags: ""
exclude:
- compiler: gcc
version: 21
- compiler: gcc
version: 20
- compiler: gcc
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Some of the extras are available only with C++20 or later.

*stdx* supports:

- clang 14 through 20
- clang 14 through 21
- gcc 12 through 14

See the [full documentation](https://intel.github.io/cpp-std-extensions/).
1 change: 1 addition & 0 deletions docs/intro.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The following compilers are supported:
* clang 18
* clang 19
* clang 20
* clang 21
* gcc 12
* gcc 13
* gcc 14
Expand Down
14 changes: 7 additions & 7 deletions include/stdx/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#ifndef CONSTINIT
#ifndef __cpp_constinit
#if defined(__clang__)
#ifdef __clang__
#define CONSTINIT [[clang::require_constant_initialization]]
#else
#define CONSTINIT
Expand All @@ -23,15 +23,15 @@
#endif

#ifndef CONSTEVAL_UDL
#if defined(__clang__)
#ifdef __clang__
#define CONSTEVAL_UDL constexpr
#else
#define CONSTEVAL_UDL CONSTEVAL
#endif
#endif

#ifndef USING_ATTR_NS
#if defined(__clang__)
#ifdef __clang__
#define USING_ATTR_NS using clang:
#else
#define USING_ATTR_NS using gnu:
Expand All @@ -51,31 +51,31 @@
#endif

#ifndef MUSTTAIL
#if defined(__clang__)
#ifdef __clang__
#define MUSTTAIL [[clang::musttail]]
#else
#define MUSTTAIL
#endif
#endif

#ifndef LIFETIMEBOUND
#if defined(__clang__)
#ifdef __clang__
#define LIFETIMEBOUND [[clang::lifetimebound]]
#else
#define LIFETIMEBOUND
#endif
#endif

#define STDX_DO_PRAGMA(X) _Pragma(#X)
#if defined(__clang__)
#ifdef __clang__
#define STDX_PRAGMA(X) STDX_DO_PRAGMA(clang X)
#else
#define STDX_PRAGMA(X) STDX_DO_PRAGMA(GCC X)
#endif

#ifndef STDX_DELETED
#if __cpp_deleted_function >= 202403L
#if defined(__clang__)
#ifdef __clang__
#define STDX_DELETED(R) \
STDX_PRAGMA(diagnostic push) \
STDX_PRAGMA(diagnostic ignored "-Wunknown-warning-option") \
Expand Down
11 changes: 7 additions & 4 deletions include/stdx/ct_conversions.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <stdx/compiler.hpp>
#include <stdx/type_traits.hpp>

#include <cstddef>
#include <string_view>
Expand All @@ -9,14 +10,15 @@ namespace stdx {
inline namespace v1 {
template <typename Tag>
CONSTEVAL static auto type_as_string() -> std::string_view {
#if defined(__clang__)
#ifdef __clang__
constexpr std::string_view function_name = __PRETTY_FUNCTION__;
constexpr auto rhs = function_name.size() - 2;
#elif defined(__GNUC__) || defined(__GNUG__)
constexpr std::string_view function_name = __PRETTY_FUNCTION__;
constexpr auto rhs = function_name.size() - 51;
#else
static_assert(false, "Unknown compiler, can't build type name.");
static_assert(always_false_v<Tag>,
"Unknown compiler, can't build type name.");
#endif

constexpr auto lhs = function_name.rfind('=', rhs) + 2;
Expand All @@ -25,14 +27,15 @@ CONSTEVAL static auto type_as_string() -> std::string_view {

template <auto Value>
CONSTEVAL static auto enum_as_string() -> std::basic_string_view<char> {
#if defined(__clang__)
#ifdef __clang__
constexpr std::string_view value_string = __PRETTY_FUNCTION__;
constexpr auto rhs = value_string.size() - 2;
#elif defined(__GNUC__) || defined(__GNUG__)
constexpr std::string_view value_string = __PRETTY_FUNCTION__;
constexpr auto rhs = value_string.size() - 2;
#else
static_assert(false, "Unknown compiler, can't build type name.");
static_assert(always_false_v<Tag>,
"Unknown compiler, can't build type name.");
#endif

constexpr auto lhs = [&]() -> std::string_view::size_type {
Expand Down
2 changes: 1 addition & 1 deletion include/stdx/panic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ auto panic(Args &&...args) -> void {

#if __cplusplus >= 202002L
#define STDX_PANIC(MSG, ...) \
[] { \
[]() -> void { \
using stdx::ct_string_literals::operator""_cts; \
stdx::panic<MSG##_cts>(__VA_ARGS__); \
}()
Expand Down
4 changes: 3 additions & 1 deletion include/stdx/static_assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace stdx {
inline namespace v1 {
namespace detail {
struct ct_check_value {};

template <bool B> struct ct_check_t {
Expand All @@ -22,6 +23,7 @@ template <> struct ct_check_t<true> {
}
};
template <bool B> constexpr auto ct_check = ct_check_t<B>{};
} // namespace detail
} // namespace v1
} // namespace stdx

Expand All @@ -45,7 +47,7 @@ template <bool B> constexpr auto ct_check = ct_check_t<B>{};
#define STATIC_ASSERT(cond, ...) \
[&]<bool B>() -> bool { \
constexpr auto S = STDX_CT_FORMAT(__VA_ARGS__); \
stdx::ct_check<B>.template emit<S>(); \
stdx::detail::ct_check<B>.template emit<S>(); \
return B; \
}.template operator()<cond>()
#endif
Expand Down
2 changes: 0 additions & 2 deletions test/fail/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ function(add_test_by_compiler CPP_NAME CXX_VERSION COMPILER_ID COMPILER_VERSION)
endif()
endfunction()

add_test_by_compiler(ct_check 20 Clang 15)
add_test_by_compiler(ct_check 20 GNU 13.2)
add_test_by_compiler(static_assert 20 Clang 15)
add_test_by_compiler(static_assert 20 GNU 13.2)
add_test_by_compiler(static_assert_format 20 Clang 15)
Expand Down
11 changes: 0 additions & 11 deletions test/fail/ct_check.cpp

This file was deleted.