Small fixes

This commit is contained in:
Vladislav Oleshko 2022-05-23 20:17:49 +03:00
parent 94fa9f77f6
commit 946292747e
2 changed files with 20 additions and 18 deletions

View File

@ -265,6 +265,22 @@ namespace crow
struct has_type<T, std::tuple<T, Ts...>> : std::true_type
{};
// Find index of type in tuple
template<class T, class Tuple>
struct tuple_index;
template<class T, class... Types>
struct tuple_index<T, std::tuple<T, Types...>>
{
static const int value = 0;
};
template<class T, class U, class... Types>
struct tuple_index<T, std::tuple<U, Types...>>
{
static const int value = 1 + tuple_index<T, std::tuple<Types...>>::value;
};
// Extract element from forward tuple or get default
#ifdef CROW_CAN_USE_CPP14
template<typename T, typename Tup>
@ -288,22 +304,6 @@ namespace crow
{
return T{};
}
// Find index of type in tuple
template<class T, class Tuple>
struct tuple_index;
template<class T, class... Types>
struct tuple_index<T, std::tuple<T, Types...>>
{
static const int value = 0;
};
template<class T, class U, class... Types>
struct tuple_index<T, std::tuple<U, Types...>>
{
static const int value = 1 + tuple_index<T, std::tuple<Types...>>::value;
};
// Kind of fold expressions in C++11
template<bool...>

View File

@ -1523,8 +1523,10 @@ struct OnlyMoveConstructor
TEST_CASE("app_constructor")
{
App<NullMiddleware, OnlyMoveConstructor, FirstMW, SecondMW>
app(OnlyMoveConstructor(1), SecondMW{});
App<NullMiddleware, OnlyMoveConstructor, FirstMW<false>, SecondMW<false>>
app1(OnlyMoveConstructor(1), SecondMW<false>{});
App<NullMiddleware, OnlyMoveConstructor, FirstMW<false>, SecondMW<false>>
app2(FirstMW<false>{}, OnlyMoveConstructor(1));
} // app_constructor
TEST_CASE("middleware_blueprint")