mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-11 08:03:55 +00:00
use if constexpr under PYBIND11_CPP17 to fix compilation warning
This commit is contained in:
parent
19d8f06c52
commit
1334c7eae7
@ -438,11 +438,13 @@ struct string_caster {
|
|||||||
cast(const StringType &src, return_value_policy /* policy */, handle /* parent */) {
|
cast(const StringType &src, return_value_policy /* policy */, handle /* parent */) {
|
||||||
const char *buffer = reinterpret_cast<const char *>(src.data());
|
const char *buffer = reinterpret_cast<const char *>(src.data());
|
||||||
auto nbytes = ssize_t(src.size() * sizeof(CharT));
|
auto nbytes = ssize_t(src.size() * sizeof(CharT));
|
||||||
if (std::is_same<CharT, uint8_t>::value
|
|
||||||
#if defined(PYBIND11_CPP17)
|
#if defined(PYBIND11_CPP17)
|
||||||
|| std::is_same<CharT, std::byte>::value
|
if constexpr (std::is_same<CharT, uint8_t>::value ||
|
||||||
|
std::is_same<CharT, std::byte>::value)
|
||||||
|
#else
|
||||||
|
if (std::is_same<CharT, uint8_t>::value)
|
||||||
#endif
|
#endif
|
||||||
) {
|
{
|
||||||
return PyBytes_FromStringAndSize(buffer, nbytes);
|
return PyBytes_FromStringAndSize(buffer, nbytes);
|
||||||
} else {
|
} else {
|
||||||
handle s = decode_utfN(buffer, nbytes);
|
handle s = decode_utfN(buffer, nbytes);
|
||||||
|
Loading…
Reference in New Issue
Block a user