Skip to content

Commit

Permalink
bytes_ostream: convert write_placeholder from enable_if to concepts
Browse files Browse the repository at this point in the history
Concepts are easier to read and result in better error messages.

This change also tightens the constraint from "std::is_fundamental" to
"std::integral". The differences are floating point values, nullptr_t,
and void. The latter two are illegal/useless to write, and nobody uses
floating point values for list lengths, so everything still compiles.

Closes scylladb#8326
  • Loading branch information
avikivity authored and psarna committed Mar 22, 2021
1 parent 23057dd commit 74df677
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bytes_ostream.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "bytes.hh"
#include "hashing.hh"
#include <seastar/core/simple-stream.hh>
#include <concepts>

/**
* Utility for writing data into a buffer when its final size is not known up front.
*
Expand Down Expand Up @@ -232,9 +234,9 @@ public:
};

// Returns a place holder for a value to be written later.
template <typename T>
template <std::integral T>
inline
std::enable_if_t<std::is_fundamental<T>::value, place_holder<T>>
place_holder<T>
write_place_holder() {
return place_holder<T>{alloc(sizeof(T))};
}
Expand Down

0 comments on commit 74df677

Please sign in to comment.