forked from Kistler-Group/sdbus-cpp
fix: conditional use and tests of span (#411)
This commit is contained in:
@@ -36,8 +36,10 @@
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#if __cplusplus >= 202002L
|
||||
#include <span>
|
||||
#ifdef __has_include
|
||||
# if __has_include(<span>)
|
||||
# include <span>
|
||||
# endif
|
||||
#endif
|
||||
#include <string>
|
||||
#include <sys/types.h>
|
||||
@@ -104,7 +106,7 @@ namespace sdbus {
|
||||
Message& operator<<(const std::vector<_Element, _Allocator>& items);
|
||||
template <typename _Element, std::size_t _Size>
|
||||
Message& operator<<(const std::array<_Element, _Size>& items);
|
||||
#if __cplusplus >= 202002L
|
||||
#ifdef __cpp_lib_span
|
||||
template <typename _Element, std::size_t _Extent>
|
||||
Message& operator<<(const std::span<_Element, _Extent>& items);
|
||||
#endif
|
||||
@@ -140,7 +142,7 @@ namespace sdbus {
|
||||
Message& operator>>(std::vector<_Element, _Allocator>& items);
|
||||
template <typename _Element, std::size_t _Size>
|
||||
Message& operator>>(std::array<_Element, _Size>& items);
|
||||
#if __cplusplus >= 202002L
|
||||
#ifdef __cpp_lib_span
|
||||
template <typename _Element, std::size_t _Extent>
|
||||
Message& operator>>(std::span<_Element, _Extent>& items);
|
||||
#endif
|
||||
@@ -339,7 +341,7 @@ namespace sdbus {
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
#ifdef __cpp_lib_span
|
||||
template <typename _Element, std::size_t _Extent>
|
||||
inline Message& Message::operator<<(const std::span<_Element, _Extent>& items)
|
||||
{
|
||||
@@ -498,7 +500,7 @@ namespace sdbus {
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
#ifdef __cpp_lib_span
|
||||
template <typename _Element, std::size_t _Extent>
|
||||
inline Message& Message::operator>>(std::span<_Element, _Extent>& items)
|
||||
{
|
||||
|
@@ -35,8 +35,10 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#if __cplusplus >= 202002L
|
||||
#include <span>
|
||||
#ifdef __has_include
|
||||
# if __has_include(<span>)
|
||||
# include <span>
|
||||
# endif
|
||||
#endif
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
@@ -399,7 +401,7 @@ namespace sdbus {
|
||||
}
|
||||
};
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
#ifdef __cpp_lib_span
|
||||
template <typename _Element, std::size_t _Extent>
|
||||
struct signature_of<std::span<_Element, _Extent>>
|
||||
{
|
||||
|
@@ -311,7 +311,7 @@ TEST(AMessage, CanCarryDBusArrayOfNontrivialTypesGivenAsStdArray)
|
||||
ASSERT_THAT(dataRead, Eq(dataWritten));
|
||||
}
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
#ifdef __cpp_lib_span
|
||||
TEST(AMessage, CanCarryDBusArrayOfTrivialTypesGivenAsStdSpan)
|
||||
{
|
||||
auto msg = sdbus::createPlainMessage();
|
||||
@@ -378,7 +378,7 @@ TEST(AMessage, ThrowsWhenDestinationStdArrayIsTooSmallDuringDeserialization)
|
||||
ASSERT_THROW(msg >> dataRead, sdbus::Error);
|
||||
}
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
#ifdef __cpp_lib_span
|
||||
TEST(AMessage, ThrowsWhenDestinationStdSpanIsTooSmallDuringDeserialization)
|
||||
{
|
||||
auto msg = sdbus::createPlainMessage();
|
||||
|
@@ -88,13 +88,13 @@ namespace
|
||||
TYPE(sdbus::ObjectPath)HAS_DBUS_TYPE_SIGNATURE("o")
|
||||
TYPE(sdbus::Signature)HAS_DBUS_TYPE_SIGNATURE("g")
|
||||
TYPE(sdbus::Variant)HAS_DBUS_TYPE_SIGNATURE("v")
|
||||
TYPE(std::variant<int16_t, std::string>)HAS_DBUS_TYPE_SIGNATURE("v")
|
||||
TYPE(sdbus::UnixFd)HAS_DBUS_TYPE_SIGNATURE("h")
|
||||
TYPE(sdbus::Struct<bool>)HAS_DBUS_TYPE_SIGNATURE("(b)")
|
||||
TYPE(sdbus::Struct<uint16_t, double, std::string, sdbus::Variant>)HAS_DBUS_TYPE_SIGNATURE("(qdsv)")
|
||||
TYPE(std::vector<int16_t>)HAS_DBUS_TYPE_SIGNATURE("an")
|
||||
TYPE(std::array<int16_t, 3>)HAS_DBUS_TYPE_SIGNATURE("an")
|
||||
TYPE(std::variant<int16_t, std::string>)HAS_DBUS_TYPE_SIGNATURE("v")
|
||||
#if __cplusplus >= 202002L
|
||||
#ifdef __cpp_lib_span
|
||||
TYPE(std::span<int16_t>)HAS_DBUS_TYPE_SIGNATURE("an")
|
||||
#endif
|
||||
TYPE(SomeEnumClass)HAS_DBUS_TYPE_SIGNATURE("y")
|
||||
@@ -138,13 +138,13 @@ namespace
|
||||
, sdbus::ObjectPath
|
||||
, sdbus::Signature
|
||||
, sdbus::Variant
|
||||
, std::variant<int16_t, std::string>
|
||||
, sdbus::UnixFd
|
||||
, sdbus::Struct<bool>
|
||||
, sdbus::Struct<uint16_t, double, std::string, sdbus::Variant>
|
||||
, std::vector<int16_t>
|
||||
, std::array<int16_t, 3>
|
||||
, std::variant<int16_t, std::string>
|
||||
#if __cplusplus >= 202002L
|
||||
#ifdef __cpp_lib_span
|
||||
, std::span<int16_t>
|
||||
#endif
|
||||
, SomeEnumClass
|
||||
|
Reference in New Issue
Block a user