Check for consteval support
This commit is contained in:
parent
4d0230cc25
commit
2c8c0ab45e
|
@ -134,7 +134,11 @@ static const constexpr char css[] = R"EOF(
|
||||||
)EOF";
|
)EOF";
|
||||||
#define CSS_LEN sizeof(css) / sizeof(css[0]) - 1
|
#define CSS_LEN sizeof(css) / sizeof(css[0]) - 1
|
||||||
|
|
||||||
|
#ifdef __cpp_consteval
|
||||||
const uint64_t css_hash = FastHashConstEval(css, CSS_LEN, 0);
|
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) {
|
void css_route(const httplib::Request& req, httplib::Response& res) {
|
||||||
res.set_header("ETag", std::string(1, '"') + std::to_string(css_hash) + '"');
|
res.set_header("ETag", std::string(1, '"') + std::to_string(css_hash) + '"');
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
|
||||||
// Compression function for Merkle-Damgard construction.
|
// Compression function for Merkle-Damgard construction.
|
||||||
// This function is generated using the framework provided.
|
// This function is generated using the framework provided.
|
||||||
//#define mix(h) ({
|
//#define mix(h) ({
|
||||||
|
@ -75,6 +77,8 @@ constexpr uint64_t FastHash(const char* str, size_t size, uint64_t seed/*, uint6
|
||||||
return mix(h);
|
return mix(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __cpp_consteval
|
||||||
consteval uint64_t FastHashConstEval(const char* str, size_t size, uint64_t seed) {
|
consteval uint64_t FastHashConstEval(const char* str, size_t size, uint64_t seed) {
|
||||||
return FastHash(str, size, seed);
|
return FastHash(str, size, seed);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue