Browse Source

兼容gcc 10的concept

tags/2.9.10
tearshark 4 years ago
parent
commit
e986686761
3 changed files with 14 additions and 12 deletions
  1. 3
    2
      CMakeLists.txt
  2. 10
    9
      librf/src/type_concept.inl
  3. 1
    1
      vs_proj/librf.vcxproj

+ 3
- 2
CMakeLists.txt View File

elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "/std:c++latest /await /EHsc") set(CMAKE_CXX_FLAGS "/std:c++latest /await /EHsc")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "-std=c++2a -fcoroutines")
set(CMAKE_CXX_FLAGS "-std=c++2a -fcoroutines -fconcepts-diagnostics-depth=8")
endif() endif()
if (UNIX) if (UNIX)
endif() endif()
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "C++ flags: ${CMAKE_CXX_FLAGS}") message(STATUS "C++ flags: ${CMAKE_CXX_FLAGS}")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
option(OPT_USE_CONCEPT "Use conecpt instead of enable_if" ON) option(OPT_USE_CONCEPT "Use conecpt instead of enable_if" ON)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
option(OPT_USE_CONCEPT "Use conecpt instead of enable_if" OFF)
option(OPT_USE_CONCEPT "Use conecpt instead of enable_if" ON)
else() else()
option(OPT_USE_CONCEPT "Use conecpt instead of enable_if" OFF) option(OPT_USE_CONCEPT "Use conecpt instead of enable_if" OFF)
endif() endif()

+ 10
- 9
librf/src/type_concept.inl View File

template<typename T> template<typename T>
concept _AwaitorT = requires(T&& v) concept _AwaitorT = requires(T&& v)
{ {
{ v.await_ready() } ->bool;
{ v.await_ready() } ->std::same_as<bool>;
{ v.await_suspend(std::declval<std::experimental::coroutine_handle<promise_t<>>>()) }; { v.await_suspend(std::declval<std::experimental::coroutine_handle<promise_t<>>>()) };
{ v.await_resume() }; { v.await_resume() };
requires traits::is_valid_await_suspend_return_v< requires traits::is_valid_await_suspend_return_v<
template<typename T> template<typename T>
concept _CallableT = std::invocable<T>; concept _CallableT = std::invocable<T>;
template<typename T>
concept _GeneratorT = std::is_same_v<T, generator_t<_Ty>>;
//template<typename T>
//concept _GeneratorT = std::is_same_v<T, generator_t<T>>;
template<typename T> template<typename T>
concept _AwaitableT = requires(T&& v) concept _AwaitableT = requires(T&& v)
template<typename T> template<typename T>
concept _IteratorT = requires(T&& u, T&& v) concept _IteratorT = requires(T&& u, T&& v)
{ {
{ ++u }->T;
{ u != v } ->bool;
{ ++u } ->std::common_with<T>;
{ u != v } ->std::same_as<bool>;
{ *u }; { *u };
}; };
template<typename T, typename E> template<typename T, typename E>
concept _IteratorOfT = _IteratorT<T> && requires(T&& u) concept _IteratorOfT = _IteratorT<T> && requires(T&& u)
{ {
{ *u } ->std::same_as<E&>;
{ *u } ->std::common_with<E&>;
}; };
template<typename T> template<typename T>
template<typename T, typename E> template<typename T, typename E>
concept _ContainerOfT = _ContainerT<T> && requires(T&& v) concept _ContainerOfT = _ContainerT<T> && requires(T&& v)
{ {
requires std::is_same_v<E, remove_cvref_t<decltype(*std::begin(v))>>;
{ *std::begin(v) } ->std::common_with<E&>;
//requires std::is_same_v<E, remove_cvref_t<decltype(*std::begin(v))>>;
}; };
#define COMMA_RESUMEF_ENABLE_IF_TYPENAME() #define COMMA_RESUMEF_ENABLE_IF_TYPENAME()
#define _HasStateT typename #define _HasStateT typename
#define _FutureT typename #define _FutureT typename
#define _CallableT typename #define _CallableT typename
#define _GeneratorT typename
//#define _GeneratorT typename
#define _AwaitableT typename #define _AwaitableT typename
#define _WhenTaskT typename #define _WhenTaskT typename
#define _IteratorT typename #define _IteratorT typename
{ v[0] }; { v[0] };
{ v._Lock_ref(v[0]) }; { v._Lock_ref(v[0]) };
{ v._Try_lock_ref(v[0]) }; { v._Try_lock_ref(v[0]) };
{ v._Unlock_ref(v[0]) } ->void;
{ v._Unlock_ref(v[0]) } ->std::same_as<void>;
{ v._Yield() }; { v._Yield() };
{ v._ReturnValue() }; { v._ReturnValue() };
{ v._ReturnValue(0) }; { v._ReturnValue(0) };

+ 1
- 1
vs_proj/librf.vcxproj View File

</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<PlatformToolset>ClangCL</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">

Loading…
Cancel
Save