Skip to content

Commit

Permalink
Update to C++23 standard
Browse files Browse the repository at this point in the history
  • Loading branch information
chronoxor committed Oct 29, 2023
1 parent c2de561 commit c6f8ff5
Show file tree
Hide file tree
Showing 30 changed files with 840 additions and 843 deletions.
4 changes: 2 additions & 2 deletions examples/string_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ class Date
template <>
struct fmt::formatter<Date>
{
constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); }
constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); }

template <typename FormatContext>
auto format(const Date& date, FormatContext& ctx) -> decltype(ctx.out())
{
return format_to(ctx.out(), "{}-{}-{}", date.year(), date.month(), date.day());
return fmt::format_to(ctx.out(), "{}-{}-{}", date.year(), date.month(), date.day());
}
};

Expand Down
3 changes: 1 addition & 2 deletions include/common/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ class Function<R(Args...), Capacity>

static const size_t StorageSize = Capacity - sizeof(Invoker) - sizeof(Manager);
static const size_t StorageAlign = 8;
using Storage = typename std::aligned_storage<StorageSize, StorageAlign>::type;

Storage _data;
alignas(StorageAlign) std::byte _data[StorageSize];
Invoker _invoker;
Manager _manager;

Expand Down
2 changes: 1 addition & 1 deletion include/errors/exceptions_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ExceptionsHandler : public CppCommon::Singleton<ExceptionsHandler>
#else
static const size_t StorageAlign = 8;
#endif
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];

ExceptionsHandler();
};
Expand Down
2 changes: 1 addition & 1 deletion include/filesystem/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class File : public Path, public Reader, public Writer

static const size_t StorageSize = 72;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example filesystem_file.cpp Filesystem file example */
Expand Down
2 changes: 1 addition & 1 deletion include/system/dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class DLL

static const size_t StorageSize = 48;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];

//! Resolve dynamic link library symbol by the given name
/*!
Expand Down
2 changes: 1 addition & 1 deletion include/system/pipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Pipe : public Reader, public Writer
#else
static const size_t StorageAlign = 8;
#endif
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example system_pipe.cpp Pipe example */
Expand Down
2 changes: 1 addition & 1 deletion include/system/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class Process
#else
static const size_t StorageAlign = 8;
#endif
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];

Process();
Process(uint64_t pid);
Expand Down
2 changes: 1 addition & 1 deletion include/system/shared_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class SharedMemory

static const size_t StorageSize = 64;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];

std::string _name;
size_t _size;
Expand Down
2 changes: 1 addition & 1 deletion include/system/stack_trace_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class StackTraceManager : public CppCommon::Singleton<StackTraceManager>

static const size_t StorageSize = 4;
static const size_t StorageAlign = 1;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];

StackTraceManager();
};
Expand Down
6 changes: 3 additions & 3 deletions include/system/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class StdInput : public Reader

static const size_t StorageSize = 8;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

//! Standard output stream
Expand Down Expand Up @@ -117,7 +117,7 @@ class StdOutput : public Writer

static const size_t StorageSize = 8;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

//! Standard error stream
Expand Down Expand Up @@ -169,7 +169,7 @@ class StdError : public Writer

static const size_t StorageSize = 8;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

} // namespace CppCommon
Expand Down
2 changes: 1 addition & 1 deletion include/threads/barrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Barrier

static const size_t StorageSize = 128;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example threads_barrier.cpp Barrier synchronization primitive example */
Expand Down
2 changes: 1 addition & 1 deletion include/threads/condition_variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class ConditionVariable

static const size_t StorageSize = 48;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example threads_condition_variable.cpp Condition variable synchronization primitive example */
Expand Down
2 changes: 1 addition & 1 deletion include/threads/critical_section.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class CriticalSection

static const size_t StorageSize = 64;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];

//! Get the native critical section handler
void* native() noexcept;
Expand Down
2 changes: 1 addition & 1 deletion include/threads/event_auto_reset.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class EventAutoReset

static const size_t StorageSize = 128;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example threads_event_auto_reset.cpp Auto-reset event synchronization primitive example */
Expand Down
2 changes: 1 addition & 1 deletion include/threads/event_manual_reset.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class EventManualReset

static const size_t StorageSize = 128;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example threads_event_manual_reset.cpp Manual-reset event synchronization primitive example */
Expand Down
2 changes: 1 addition & 1 deletion include/threads/file_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class FileLock

static const size_t StorageSize = 48;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example threads_file_lock.cpp File-lock synchronization primitive example */
Expand Down
2 changes: 1 addition & 1 deletion include/threads/mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Mutex

static const size_t StorageSize = 64;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example threads_mutex.cpp Mutex synchronization primitive example */
Expand Down
2 changes: 1 addition & 1 deletion include/threads/named_condition_variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class NamedConditionVariable

static const size_t StorageSize = 168;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example threads_named_condition_variable.cpp Named condition variable synchronization primitive example */
Expand Down
2 changes: 1 addition & 1 deletion include/threads/named_critical_section.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class NamedCriticalSection

static const size_t StorageSize = 256;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example threads_named_critical_section.cpp Named critical section synchronization primitive example */
Expand Down
2 changes: 1 addition & 1 deletion include/threads/named_event_auto_reset.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class NamedEventAutoReset

static const size_t StorageSize = 136;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example threads_named_event_auto_reset.cpp Named auto-reset event synchronization primitive example */
Expand Down
2 changes: 1 addition & 1 deletion include/threads/named_event_manual_reset.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class NamedEventManualReset

static const size_t StorageSize = 136;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example threads_named_event_manual_reset.cpp Named manual-reset event synchronization primitive example */
Expand Down
2 changes: 1 addition & 1 deletion include/threads/named_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class NamedMutex

static const size_t StorageSize = 136;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example threads_named_mutex.cpp Named mutex synchronization primitive example */
Expand Down
2 changes: 1 addition & 1 deletion include/threads/named_rw_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class NamedRWLock

static const size_t StorageSize = 184;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example threads_named_rw_lock.cpp Named read/write lock synchronization primitive example */
Expand Down
2 changes: 1 addition & 1 deletion include/threads/named_semaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class NamedSemaphore

static const size_t StorageSize = 56;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example threads_named_semaphore.cpp Named semaphore synchronization primitive example */
Expand Down
2 changes: 1 addition & 1 deletion include/threads/rw_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class RWLock
static const size_t StorageSize = 56;
#endif
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example threads_rw_lock.cpp Read/Write lock synchronization primitive example */
Expand Down
2 changes: 1 addition & 1 deletion include/threads/semaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Semaphore

static const size_t StorageSize = 40;
static const size_t StorageAlign = 8;
std::aligned_storage<StorageSize, StorageAlign>::type _storage;
alignas(StorageAlign) std::byte _storage[StorageSize];
};

/*! \example threads_semaphore.cpp Semaphore synchronization primitive example */
Expand Down
Loading

0 comments on commit c6f8ff5

Please sign in to comment.