Check for consteval support

This commit is contained in:
blankie 2023-05-12 17:28:28 +07:00
parent 4d0230cc25
commit 2c8c0ab45e
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
2 changed files with 8 additions and 0 deletions

View File

@ -134,7 +134,11 @@ static const constexpr char css[] = R"EOF(
)EOF";
#define CSS_LEN sizeof(css) / sizeof(css[0]) - 1
#ifdef __cpp_consteval
const uint64_t css_hash = FastHashConstEval(css, CSS_LEN, 0);
#else
const uint64_t css_hash = FastHash(css, CSS_LEN, 0);
#endif
void css_route(const httplib::Request& req, httplib::Response& res) {
res.set_header("ETag", std::string(1, '"') + std::to_string(css_hash) + '"');

View File

@ -39,6 +39,8 @@
#pragma once
#include <version>
// Compression function for Merkle-Damgard construction.
// This function is generated using the framework provided.
//#define mix(h) ({
@ -75,6 +77,8 @@ constexpr uint64_t FastHash(const char* str, size_t size, uint64_t seed/*, uint6
return mix(h);
}
#ifdef __cpp_consteval
consteval uint64_t FastHashConstEval(const char* str, size_t size, uint64_t seed) {
return FastHash(str, size, seed);
}
#endif