Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example fails to compile (gcc 12.2.1) #4

Open
SnapperTT opened this issue Sep 6, 2023 · 0 comments
Open

Example fails to compile (gcc 12.2.1) #4

SnapperTT opened this issue Sep 6, 2023 · 0 comments

Comments

@SnapperTT
Copy link

Nice library. Here are the issues:

  1. example.cpp needs a #include <cstdint> for std::uint32_t support

  2. Here is the other compile errors:

[ 25%] Building CXX object example/CMakeFiles/examples.dir/main.cpp.o
cd /home/twigger/faststring/FastString/example && /usr/bin/c++  -I/home/twigger/faststring/FastString/include -O3 -O3 -DNDEBUG -std=c++20 -Wall -Wextra -pedantic -Werror -MD -MT example/CMakeFiles/examples.dir/main.cpp.o -MF CMakeFiles/examples.dir/main.cpp.o.d -o CMakeFiles/examples.dir/main.cpp.o -c /home/twigger/faststring/FastString/example/main.cpp
/home/twigger/faststring/FastString/example/main.cpp: In function ‘int main()’:
/home/twigger/faststring/FastString/example/main.cpp:39:51: error: ‘std::basic_string_view<char>{2, ((const char*)(& e.fss::basic_str<char, 7, std::char_traits<char> >::buffer_))}’ is not a constant expression
   39 |     constexpr auto e_sub_str = e.str().substr(0, 2);    // e_sub_str is "ab"
      |                                                   ^
/home/twigger/faststring/FastString/example/main.cpp:96:40: error: ‘std::basic_string_view<char>{4, ((const char*)(& t.main()::test_struct::c_.fss::basic_str<char, 7, std::char_traits<char> >::buffer_))}’ is not a constant expression
   96 |     constexpr const auto t_a = t.get_c();
      |                                        ^
make[2]: *** [example/CMakeFiles/examples.dir/build.make:79: example/CMakeFiles/examples.dir/main.cpp.o] Error 1
  1. Finally you use std::size_t for your size type. This needlessly makes, eg, string64 take up 8 more bytes than necessary. Why not use something like uint8_t and have a static_assert that the size is suitable for the capacity. Or even better, have a template argument for the size type, eg using string64 = fss::fixed_size_str<62, std::uint8_t>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant