From 552c2deca84d0588d3038c9d3fe6419582d5a0ce Mon Sep 17 00:00:00 2001 From: doggo Date: Mon, 7 Jun 2021 09:03:04 -0500 Subject: [PATCH] Changed initial check to all static assertions --- include/log_consts.hpp | 4 ++-- main.cpp | 12 +++--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/include/log_consts.hpp b/include/log_consts.hpp index cd84770..b0c40bd 100644 --- a/include/log_consts.hpp +++ b/include/log_consts.hpp @@ -1,5 +1,5 @@ #pragma once -// `max_log_size` must be divisible by `pre_log_size` -constexpr unsigned max_log_size = 100; // Setting to 0 does not compile logging +// Setting both values to 0 does not compile logging +constexpr unsigned max_log_size = 100; constexpr unsigned pre_log_size = 10; diff --git a/main.cpp b/main.cpp index 7f85baf..a013878 100644 --- a/main.cpp +++ b/main.cpp @@ -22,15 +22,9 @@ void SaveSig(int s) int main(int argc, char **argv) { - static_assert(pre_log_size <= max_log_size, "`max_log_size` must be larger than `pre_log_size`."); - if constexpr (max_log_size && pre_log_size) - { - if (max_log_size % pre_log_size) - { - std::cerr << "`max_log_size` must be a multiple of `pre_log_size`."; - return 0; - } - } + static_assert(bool(max_log_size) == bool(pre_log_size), "You must either utilize both or neither logging variables.\n"); + static_assert(max_log_size >= pre_log_size, "The maximum log size must be larger than or equal to the amount preallocated.\n"); + static_assert(!max_log_size || !(max_log_size % pre_log_size), "The maximum log size must be divisible by the preallocation size.\n"); if (argc != 4) {