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
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RslUtilRecipe(ConanFile):
exports_sources = "CMakeLists.txt", "include/*", "test/*", "cmake/*"
def requirements(self):
if self.options.tests:
self.requires("gtest/1.14.0")
self.requires("gtest/1.17.0")

def layout(self):
cmake_layout(self)
Expand Down
6 changes: 3 additions & 3 deletions include/rsl/_impl/format/fmt_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ struct Replacement final : _impl::Parser {

using _impl::Parser::Parser;

constexpr void add_style(FormatString& out, bool enable) const {
consteval void add_style(FormatString& out, bool enable) const {
if (!style_tags.empty()) {
out.string += style_separator;
out.style_tags.emplace_back(style_tags, enable);
}
}

constexpr void render(FormatString& out) const {
consteval void render(FormatString& out) const {
if (kind == ReplacementType::invalid) {
// todo emit error?
return;
Expand Down Expand Up @@ -223,7 +223,7 @@ struct FormatParser : _impl::Parser {

FormatString result;

constexpr void push_text(int start, int end) { result.string += data.substr(start, end - start); }
consteval void push_text(int start, int end) { result.string += data.substr(start, end - start); }

consteval static std::meta::info get_arg_accessor(std::size_t index) {
return substitute(^^Accessor, {std::meta::reflect_constant(index)});
Expand Down
8 changes: 6 additions & 2 deletions include/rsl/_impl/macro/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@
#define RSL_VERSION_ENCODE(major, minor, patch) ((major) * 1000000 + (minor) * 1000 + (patch))

#if defined(__clang__)
# define RSL_COMPILER RSL_COMPILER_CLANG
# define RSL_COMPILER RSL_COMPILER_CLANG
# define RSL_COMPILER_ID clang
# define RSL_COMPILER_VERSION \
RSL_VERSION_ENCODE(__clang_major__, __clang_minor__, __clang_patchlevel__)
#elif defined(__GNUC__)
# define RSL_COMPILER RSL_COMPILER_GCC
# define RSL_COMPILER_ID GCC
# define RSL_COMPILER_VERSION RSL_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
#elif defined(_MSC_VER)
# define RSL_COMPILER RSL_COMPILER_MSVC
# define RSL_COMPILER RSL_COMPILER_MSVC
# define RSL_COMPILER_ID MSVC
# if defined(_MSC_FULL_VER)
# define RSL_COMPILER_VERSION _MSC_FULL_VER
# else
Expand All @@ -25,6 +28,7 @@

#else
# define RSL_COMPILER RSL_COMPILER_UNKNOWN
# define RSL_COMPILER_ID UNKNOWN
# define RSL_COMPILER_VERSION 0
#endif

Expand Down
46 changes: 46 additions & 0 deletions include/rsl/_impl/macro/diagnostic.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once

#include "compiler.hpp"

#define RSL_STRINGIZE_IMPL(x) #x
#define RSL_STRINGIZE(x) RSL_STRINGIZE_IMPL(x)
#if RSL_COMPILER == RSL_COMPILER_MSVC
# define RSL_PRAGMA(x) __pragma(x)
#else
# define RSL_PRAGMA(x) _Pragma(RSL_STRINGIZE(x))
#endif


#if RSL_COMPILER == RSL_COMPILER_MSVC
# define RSL_DIAG_PUSH RSL_PRAGMA(warning(push))
# define RSL_DIAG_POP RSL_PRAGMA(warning(pop))
# define RSL_DIAG_DISABLE(id) RSL_PRAGMA(warning(disable : RSL_DIAGS_##id))
# define RSL_DIAG_ERROR(id) RSL_PRAGMA(warning(error : RSL_DIAGS_##id))
#elif RSL_COMPILER == RSL_COMPILER_GCC || RSL_COMPILER == RSL_COMPILER_CLANG
# define RSL_DIAG_PUSH RSL_PRAGMA(RSL_COMPILER_ID diagnostic push)
# define RSL_DIAG_POP RSL_PRAGMA(RSL_COMPILER_ID diagnostic pop)
# define RSL_DIAG_DISABLE(w) RSL_PRAGMA(RSL_COMPILER_ID diagnostic ignored RSL_DIAGS_##w)
# define RSL_DIAG_ERROR(w) RSL_PRAGMA(RSL_COMPILER_ID diagnostic error RSL_DIAGS_##w)
#else
# warning "Unsupported compiler"
#endif

#define RSL_IMPL_CONSUME(...)
#define RSL_DIAG_push RSL_DIAG_PUSH RSL_IMPL_CONSUME
#define RSL_DIAG_pop RSL_DIAG_POP RSL_IMPL_CONSUME
#define RSL_DIAG_disable RSL_DIAG_DISABLE
#define RSL_DIAG_error RSL_DIAG_ERROR

// Diagnostic map
#if RSL_COMPILER == RSL_COMPILER_MSVC
# define RSL_DIAGS_literal_suffix 4455
# define RSL_DIAGS_narrowing 4838
#elif RSL_COMPILER == RSL_COMPILER_GCC
# define RSL_DIAGS_literal_suffix "-Wliteral-suffix"
# define RSL_DIAGS_narrowing "-Wnarrowing"
#elif RSL_COMPILER == RSL_COMPILER_CLANG
# define RSL_DIAGS_literal_suffix "-Wuser-defined-literals"
# define RSL_DIAGS_narrowing "-Wc++11-narrowing"
#else
# warning "Unsupported compiler"
#endif
19 changes: 19 additions & 0 deletions include/rsl/_impl/macro/loop.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#define RSL_IMPL_PARENS ()

#define RSL_IMPL_EXPAND(...) RSL_IMPL_EXPAND4(RSL_IMPL_EXPAND4(RSL_IMPL_EXPAND4(RSL_IMPL_EXPAND4(__VA_ARGS__))))
#define RSL_IMPL_EXPAND4(...) RSL_IMPL_EXPAND3(RSL_IMPL_EXPAND3(RSL_IMPL_EXPAND3(RSL_IMPL_EXPAND3(__VA_ARGS__))))
#define RSL_IMPL_EXPAND3(...) RSL_IMPL_EXPAND2(RSL_IMPL_EXPAND2(RSL_IMPL_EXPAND2(RSL_IMPL_EXPAND2(__VA_ARGS__))))
#define RSL_IMPL_EXPAND2(...) RSL_IMPL_EXPAND1(RSL_IMPL_EXPAND1(RSL_IMPL_EXPAND1(RSL_IMPL_EXPAND1(__VA_ARGS__))))
#define RSL_IMPL_EXPAND1(...) __VA_ARGS__

#define RSL_IMPL_FOR_EACH_DELIM(macro, delim, ...) \
__VA_OPT__(RSL_IMPL_EXPAND(RSL_IMPL_FOR_EACH_DELIM_HELPER(macro, delim, __VA_ARGS__)))
#define RSL_IMPL_FOR_EACH_DELIM_HELPER(macro, delim, a1, ...) \
macro(a1) \
__VA_OPT__(delim() RSL_IMPL_FOR_EACH_DELIM_AGAIN RSL_IMPL_PARENS (macro, delim, __VA_ARGS__))
#define RSL_IMPL_FOR_EACH_DELIM_AGAIN() RSL_IMPL_FOR_EACH_DELIM_HELPER

#define RSL_IMPL_DELIM_NONE()
#define RSL_IMPL_DELIM_COMMA() ,
2 changes: 1 addition & 1 deletion include/rsl/_impl/member_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct MemberAccessor {
static consteval bool has_member(std::string_view name) { return get_index_of(name) != -1UZ; }
};

template <auto... Members>
template <std::meta::info... Members>
constexpr inline MemberAccessor<Members...> member_cache{};

consteval auto cache_members(auto&& member_range) {
Expand Down
2 changes: 1 addition & 1 deletion include/rsl/annotations
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include <rsl/meta_traits>
#include <rsl/meta>
#include <rsl/serialize> // for preferred_name annotation

#include <rsl/serializer/repr.hpp>
Expand Down
Loading