Open uchenily opened 1 month ago
I notice that this class has implemented operator const T*
method, but I think we still need to explicit cast to const char *
here(return (const char *)raw_data
), otherwise, the compiler will report an error:
test_huffman.cpp:438:35: error: call to consteval function ‘data.huffman_compressor<detail::huffman_string_container<char, 48>{"A long string to be compressed at compiled time"}>::data().detail::huffman_string_container<char, 48>::operator const char()’ is not a constant expression
438 | std::cout << std::string_view{(const char )data.data(), data.size()} << '\n';
| ^~~~~~~~~
test_huffman.cpp:438:58: error: call to non-‘constexpr’ function ‘auto huffman_compressor~~~~~^~
test_huffman.cpp:371:10: note: ‘auto huffman_compressor
I see, good catch. I would make the change from return raw_data
to return raw_data.data
. It might also make sense to just get rid of huffman_string_container
's user-defined conversion and replace it with an operator[]
; that's all the compressor code really needs.
The data() method seems to get a wrong return type:
Should
return raw_data
here be changed toreturn raw_data.data
?