mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-30 06:18:50 +08:00
Enabled etl::overload for C++11 & C++14
This commit is contained in:
parent
26cf2afd7f
commit
8e83a2655b
@ -35,10 +35,9 @@ SOFTWARE.
|
||||
#include "utility.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
/// Variadic template definition of overload for C++17 and above.
|
||||
//*************************************************************************
|
||||
@ -61,8 +60,39 @@ namespace etl
|
||||
{
|
||||
return overload<TOverloads...>{ etl::forward<TOverloads>(overloads)... };
|
||||
}
|
||||
#elif ETL_USING_CPP11
|
||||
//*************************************************************************
|
||||
/// Variadic template definition of overload for C++11 & C++14.
|
||||
//*************************************************************************
|
||||
template <typename... TRest>
|
||||
struct overload;
|
||||
|
||||
//*************************************************************************
|
||||
template <typename TOverload, typename... TRest>
|
||||
struct overload<TOverload, TRest...> : TOverload, overload<TRest...>
|
||||
{
|
||||
overload(TOverload ovl0, TRest... rest) : TOverload(ovl0), overload<TRest...>(rest...) {}
|
||||
|
||||
using TOverload::operator();
|
||||
using overload<TRest...>::operator();
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
template <typename TOverload>
|
||||
struct overload<TOverload> : TOverload
|
||||
{
|
||||
overload(TOverload ovl0) : TOverload(ovl0) {}
|
||||
|
||||
using TOverload::operator();
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
template <typename... TRest>
|
||||
overload<TRest...> make_overload(TRest... overloads)
|
||||
{
|
||||
return overload<TRest...>(overloads...);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -30,7 +30,7 @@ SOFTWARE.
|
||||
|
||||
#include "etl/overload.h"
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
#if ETL_USING_CPP11
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -100,6 +100,7 @@ namespace
|
||||
CHECK(result.bs == true);
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP_17
|
||||
//*************************************************************************
|
||||
TEST(test_overload_lambdas_initializer_list)
|
||||
{
|
||||
@ -136,6 +137,7 @@ namespace
|
||||
CHECK(result.bd == false);
|
||||
CHECK(result.bs == true);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_visitor_overload)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user