C++20 compatability -- std::result_of with std::invoke_result (#392)

* Replaced result_of with invoke_result_t.
* Fixed a few compile errors and updated CMakeLists.
* Updated Cloud CI
This commit is contained in:
FriendlyFire 2020-12-16 08:51:26 -05:00 committed by GitHub
parent 2fca06ff6d
commit e28f559d32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 20 additions and 20 deletions

View File

@ -43,7 +43,7 @@ cmake_minimum_required(VERSION 3.2)
project(g3log CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT CMAKE_BUILD_TYPE AND NOT (MSVC_IDE OR XCODE))

View File

@ -2,7 +2,7 @@ environment:
P: "c:/projects/libs"
# Operating system (build VM template)
os: Visual Studio 2015
os: Visual Studio 2017
# scripts that are called at very beginning, before repo cloning
#init:
@ -21,12 +21,12 @@ install:
before_build:
- cd c:\projects\g3log\
- mkdir build
- cd build
- cd build
build_script:
- cmake -G "Visual Studio 14 2015 Win64" -DADD_G3LOG_UNIT_TEST=ON -DUSE_DYNAMIC_LOGGING_LEVELS=ON -DCHANGE_G3LOG_DEBUG_TO_DBUG=ON -DCMAKE_INSTALL_PREFIX=c:\g3log ..
- cmake -G "Visual Studio 15 2017 Win64" -DADD_G3LOG_UNIT_TEST=ON -DUSE_DYNAMIC_LOGGING_LEVELS=ON -DCHANGE_G3LOG_DEBUG_TO_DBUG=ON -DCMAKE_INSTALL_PREFIX=c:\g3log ..
- cmake --build . --config Release --target install
# scripts to run after build
after_build:
- cmd /c Release\g3log-FATAL-contract.exe || exit /B 0

View File

@ -8,11 +8,11 @@ apt-get install -y apt-utils | true
apt-get install -y software-properties-common | true
apt-get install -y python-software-properties
apt-get update -y
add-apt-repository -y ppa:jonathonf/gcc-7.1
apt-get update -y
add-apt-repository -y ppa:jonathonf/gcc
apt-get update -y
apt-get install -y cmake software-properties-common git make
apt-get install -y gcc-7 g++-7
apt-get install -y gcc-7 g++-7
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 90
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90
apt-get install -y unzip zlib1g-dev
apt-get install -y libboost-all-dev

View File

@ -42,9 +42,9 @@ namespace g3 {
// auto msg_call=[=](){return ("Hello from the Background");};
// auto future_msg = g3::spawn_task(msg_lambda, bgWorker.get());
template <typename Func, class BgWorker>
std::future<typename std::result_of<Func()>::type> spawn_task(Func func, BgWorker *worker)
std::future<std::invoke_result_t<Func>> spawn_task(Func func, BgWorker *worker)
{
typedef typename std::result_of<Func()>::type result_type;
typedef std::invoke_result_t<Func> result_type;
typedef std::packaged_task<result_type()> task_type;
if (nullptr == worker) {

View File

@ -70,7 +70,7 @@ namespace g3 {
}
template<typename Call, typename... Args>
auto async(Call call, Args &&... args)-> std::future< typename std::result_of<decltype(call)(T, Args...)>::type> {
auto async(Call call, Args &&... args)-> std::future<std::invoke_result_t<decltype(call), T, Args...>> {
return g3::spawn_task(std::bind(call, _real_sink.get(), std::forward<Args>(args)...), _bg.get());
}
};

View File

@ -37,12 +37,12 @@ namespace g3 {
// the returned future will contain a bad_weak_ptr exception instead of the
// call result.
template<typename AsyncCall, typename... Args>
auto call(AsyncCall func , Args&& ... args) -> std::future<typename std::result_of<decltype(func)(T, Args...)>::type> {
auto call(AsyncCall func , Args&& ... args) -> std::future<std::invoke_result_t<decltype(func), T, Args...>> {
try {
std::shared_ptr<internal::Sink<T>> sink(_sink);
return sink->async(func, std::forward<Args>(args)...);
} catch (const std::bad_weak_ptr& e) {
typedef typename std::result_of<decltype(func)(T, Args...)>::type PromiseType;
typedef std::invoke_result_t<decltype(func), T, Args...> PromiseType;
std::promise<PromiseType> promise;
promise.set_exception(std::make_exception_ptr(e));
return std::move(promise.get_future());

View File

@ -2,7 +2,7 @@
* 2012 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes
* with no warranties. This code is yours to share, use and modify with no
* strings attached and no restrictions or obligations.
*
*
* For more information see g3log/LICENSE or refer refer to http://unlicense.org
* ============================================================================*/
@ -75,9 +75,9 @@ TEST(TestOf_CopyableLambdaCall, Expecting_AllFine)
template<typename F>
std::future<typename std::result_of<F()>::type> ObsoleteSpawnTask(F f)
std::future<std::invoke_result_t<F>> ObsoleteSpawnTask(F f)
{
typedef typename std::result_of<F()>::type result_type;
typedef std::invoke_result_t<F> result_type;
typedef std::packaged_task<result_type()> task_type;
task_type task(std::move(f));
@ -119,9 +119,9 @@ namespace WORKING
std::vector<std::function<void()>> vec;
template<typename F>
std::future<typename std::result_of<F()>::type> spawn_task(F f)
std::future<std::invoke_result_t<F>> spawn_task(F f)
{
typedef typename std::result_of<F()>::type result_type;
typedef std::invoke_result_t<F> result_type;
typedef std::packaged_task<result_type()> task_type;
task_type task(std::move(f));

View File

@ -86,7 +86,7 @@ namespace testing_helpers {
template<typename Call, typename ... Args >
typename std::result_of<Call(Args...)>::type callToLogger(Call call, Args&& ... args) {
std::invoke_result_t<Call(Args...)> callToLogger(Call call, Args&& ... args) {
auto func = std::bind(call, _scope->get(), std::forward<Args>(args)...);
return func();
}