6#include "Stroika/Foundation/Cryptography/Format.h"
8namespace Stroika::Foundation::Cryptography::Digest {
12 template <
typename OUT_RESULT,
typename IN_RESULT>
13 constexpr OUT_RESULT mkReturnType_ (IN_RESULT hashVal)
15 if constexpr (constructible_from<OUT_RESULT, IN_RESULT>) {
16 return OUT_RESULT (hashVal);
18 else if constexpr (is_trivially_copyable_v<IN_RESULT> and is_trivially_copyable_v<OUT_RESULT>) {
20 size_t mBytes2Copy = std::min (
sizeof (OUT_RESULT),
sizeof (IN_RESULT));
22 DISABLE_COMPILER_GCC_WARNING_START (
"GCC diagnostic ignored \"-Wclass-memaccess\"")
23 ::memcpy (&result, &hashVal, mBytes2Copy);
24 DISABLE_COMPILER_GCC_WARNING_END (
"GCC diagnostic ignored \"-Wclass-memaccess\"")
27 else if constexpr (same_as<OUT_RESULT,
string> or same_as<OUT_RESULT, Characters::String> or same_as<OUT_RESULT, Common::GUID>) {
28 return Format<OUT_RESULT> (hashVal);
34 template <
typename OUT_RESULT,
typename IN_RESULT>
35 constexpr OUT_RESULT ConvertResult (IN_RESULT inResult)
37 return Private_::mkReturnType_<OUT_RESULT> (inResult);