Commit 8bd7220f authored by Wescoeur's avatar Wescoeur Committed by Ronan

feat(general): provide a StringLiteralList

parent ea44dce8
......@@ -21,6 +21,7 @@
#define _L_GENERAL_H_
#ifdef __cplusplus
#include <tuple>
#include <type_traits>
#endif
......@@ -103,6 +104,8 @@ void l_assert (const char *condition, const char *file, int line);
// Define an integer version like: 0xXXYYZZ, XX=MAJOR, YY=MINOR, and ZZ=PATCH.
#define L_VERSION(MAJOR, MINOR, PATCH) (((MAJOR) << 16) | ((MINOR) << 8) | (PATCH))
#define L_AUTO_CONSTEXPR_RETURN(VALUE) -> decltype(VALUE) { return VALUE; }
// -----------------------------------------------------------------------------
// Data access.
// -----------------------------------------------------------------------------
......@@ -312,7 +315,7 @@ template<std::size_t N>
using MakeIndexSequence = typename Private::MakeIndexSequence<N>::type;
// -----------------------------------------------------------------------------
// Compil-time string.
// Compile-time string.
// -----------------------------------------------------------------------------
namespace Private {
......@@ -353,6 +356,30 @@ constexpr StringLiteral<N> makeStringLiteral (RawStringLiteral<N> &raw) {
return StringLiteral<N>(raw);
}
// -----------------------------------------------------------------------------
// Compile-time string list.
// -----------------------------------------------------------------------------
template<typename... T>
using StringLiteralList = std::tuple<T...>;
constexpr StringLiteralList<> makeStringLiteralList () {
return {};
}
template<std::size_t N, typename... T>
constexpr auto makeStringLiteralList (RawStringLiteral<N> &raw, T&... list) L_AUTO_CONSTEXPR_RETURN(
std::tuple_cat(std::make_tuple(StringLiteral<N>(raw)), makeStringLiteralList(list...))
)
template<std::size_t N, typename T>
constexpr auto appendStringLiteral (
const StringLiteralList<T> &list,
const StringLiteral<N> &stringLiteral
) L_AUTO_CONSTEXPR_RETURN(
std::tuple_cat(list, stringLiteral)
)
#endif // ifdef __cplusplus
LINPHONE_END_NAMESPACE
......
......@@ -53,8 +53,6 @@
#define L_INTERNAL_SIGNAL_INDEX(NAME, LINE) L_CONCAT(lSignalIndexOf ## _, L_CONCAT(NAME ## _, LINE))
#define L_INTERNAL_META_RETURN(VALUE) -> decltype(VALUE) { return VALUE; }
// -----------------------------------------------------------------------------
// Public macros API.
// -----------------------------------------------------------------------------
......@@ -94,7 +92,7 @@
friend constexpr auto lMetaSignals ( \
LinphonePrivate::Private::MetaObjectCounter<L_INTERNAL_SIGNAL_INDEX(NAME, __LINE__) + 1> counter, \
lType **context \
) L_INTERNAL_META_RETURN( \
) L_AUTO_CONSTEXPR_RETURN( \
std::tuple_cat( \
lMetaSignals(counter.prev(), context), \
std::make_tuple(LinphonePrivate::Private::makeMetaObjectSignalInfo( \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment