Skip to content

Commit

Permalink
cmake: Add an option for using std::string
Browse files Browse the repository at this point in the history
With this basic_sstring is still available for code that needs the
extra features. It is just sstring that is aliased to std::string.

The default is still to use sstring.

Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
  • Loading branch information
espindola committed Mar 9, 2020
1 parent 25208ca commit fc0750b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ option (Seastar_EXPERIMENTAL_COROUTINES_TS
"Enable experimental support for Coroutines TS."
OFF)

option (Seastar_SSTRING
"Use seastar's own string implementation"
ON)

set (Seastar_API_LEVEL
"2"
CACHE
Expand Down Expand Up @@ -745,6 +749,10 @@ if (Seastar_EXPERIMENTAL_COROUTINES_TS)
target_compile_definitions (seastar PUBLIC SEASTAR_COROUTINES_TS)
endif ()

if (Seastar_SSTRING)
target_compile_options (seastar PUBLIC -DSEASTAR_SSTRING)
endif ()

if (Seastar_GCC6_CONCEPTS OR Concepts_FOUND)
target_compile_definitions (seastar
PUBLIC SEASTAR_HAVE_GCC6_CONCEPTS)
Expand Down
4 changes: 4 additions & 0 deletions include/seastar/core/sstring.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ namespace seastar {
template <typename char_type, typename Size, Size max_size, bool NulTerminate = true>
class basic_sstring;

#ifdef SEASTAR_SSTRING
using sstring = basic_sstring<char, uint32_t, 15>;
#else
using sstring = std::string;
#endif

template <typename char_type, typename Size, Size max_size, bool NulTerminate>
class basic_sstring {
Expand Down

1 comment on commit fc0750b

@crackcomm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I'd report an error I encountered without SEASTAR_SSTRING defined.

external/seastar/src/net/tls.cc: In lambda function:
external/seastar/src/net/tls.cc:174:26: error: 'initialized_later' is not a member of 'seastar::sstring' {aka 'std::__cxx11::basic_string<char>'}
  174 |     sstring res(sstring::initialized_later{}, size - 1);
      |                          ^~~~~~~~~~~~~~~~~

Please sign in to comment.