From 224b7616ae2b8c79f79cef66eaa794e7c988f49e Mon Sep 17 00:00:00 2001 From: Avril Date: Thu, 3 Dec 2020 17:15:30 +0000 Subject: [PATCH] no warnings on -Wall --- Makefile | 4 +++- cfrob.hpp | 6 +----- test/test.cpp | 7 ++++++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index fa98b55..c33e773 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,11 @@ test: test/test test/test: test/test.cpp - $(CXX) -I. --std=c++20 $< -o $@ + $(CXX) -I. --std=c++20 -Wall -pedantic $< -o $@ if strings $@ | grep Hello; then exit 1; fi + ./$@ strings $@ | grep bOFFE >> /dev/null + @echo "" @echo "Passed." clean: diff --git a/cfrob.hpp b/cfrob.hpp index c9c84dc..2ef6c18 100644 --- a/cfrob.hpp +++ b/cfrob.hpp @@ -9,6 +9,7 @@ namespace frob } template + requires(N > 0) struct cfrob { char out[N]{}; @@ -19,11 +20,6 @@ namespace frob out[N-1] = 0; } }; - template<> - struct cfrob<0> - { - char out[0]{}; - }; } template diff --git a/test/test.cpp b/test/test.cpp index f728bf0..51cb945 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -3,7 +3,12 @@ #include -const auto str = "Hello world."_frob; +// Can be stored as `const char` array with compile-time size for optimal use. +const auto str = "Hello world."_frob; +constexpr const char* str2 = "Hello world."_frob; + +// Can also be stored as normal `const char*` string constant pointer. +const char* str3 = "Hello world."_frob; int main() {