Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace std::result_of with std::invoke_result #392

Merged
merged 5 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

"files.associations": {
"SConscript": "python",
"*.md.html": "markdown",
"type_traits": "cpp"
}
}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions scripts/.travis-bootstrap-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/g3log/future.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/g3log/sink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/g3log/sinkhandle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
10 changes: 5 additions & 5 deletions test_unit/test_cpp_future_concepts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
* ============================================================================*/

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion test_unit/testing_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down