Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
08aeada7
Unverified
Commit
08aeada7
authored
Mar 13, 2020
by
Facundo Galán
Committed by
GitHub
Mar 13, 2020
Browse files
Replace result_of by invoke_result for C++17 and above (#2021)
Co-authored-by:
Facundo Galan
<
fgalan@danaide.com.ar
>
parent
c8a175f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
+18
-5
dlib/threads/async.h
dlib/threads/async.h
+18
-5
No files found.
dlib/threads/async.h
View file @
08aeada7
...
@@ -40,6 +40,19 @@ namespace dlib
...
@@ -40,6 +40,19 @@ namespace dlib
fun
();
fun
();
prom
.
set_value
();
prom
.
set_value
();
}
}
template
<
typename
>
struct
result_of
;
#if (__cplusplus >= 201703L || \
(defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)) && \
__cpp_lib_is_invocable >= 201703L
template
<
typename
F
,
typename
...
Args
>
struct
result_of
<
F
(
Args
...)
>
:
std
::
invoke_result
<
F
,
Args
...
>
{};
#else
template
<
typename
F
,
typename
...
Args
>
struct
result_of
<
F
(
Args
...)
>
:
std
::
result_of
<
F
&&
(
Args
&&
...)
>
{};
#endif
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -52,21 +65,21 @@ namespace dlib
...
@@ -52,21 +65,21 @@ namespace dlib
typename
Function
,
typename
Function
,
typename
...
Args
typename
...
Args
>
>
std
::
future
<
typename
std
::
result_of
<
Function
(
Args
...)
>::
type
>
async
(
std
::
future
<
typename
impl
::
result_of
<
Function
(
Args
...)
>::
type
>
async
(
thread_pool
&
tp
,
thread_pool
&
tp
,
Function
&&
f
,
Function
&&
f
,
Args
&&
...
args
Args
&&
...
args
)
)
{
{
auto
prom
=
std
::
make_shared
<
std
::
promise
<
typename
std
::
result_of
<
Function
(
Args
...)
>::
type
>>
();
auto
prom
=
std
::
make_shared
<
std
::
promise
<
typename
impl
::
result_of
<
Function
(
Args
...)
>::
type
>>
();
std
::
future
<
typename
std
::
result_of
<
Function
(
Args
...)
>::
type
>
ret
=
prom
->
get_future
();
std
::
future
<
typename
impl
::
result_of
<
Function
(
Args
...)
>::
type
>
ret
=
prom
->
get_future
();
using
bind_t
=
decltype
(
std
::
bind
(
std
::
forward
<
Function
>
(
f
),
std
::
forward
<
Args
>
(
args
)...));
using
bind_t
=
decltype
(
std
::
bind
(
std
::
forward
<
Function
>
(
f
),
std
::
forward
<
Args
>
(
args
)...));
auto
fun
=
std
::
make_shared
<
bind_t
>
(
std
::
bind
(
std
::
forward
<
Function
>
(
f
),
std
::
forward
<
Args
>
(
args
)...));
auto
fun
=
std
::
make_shared
<
bind_t
>
(
std
::
bind
(
std
::
forward
<
Function
>
(
f
),
std
::
forward
<
Args
>
(
args
)...));
tp
.
add_task_by_value
([
fun
,
prom
]()
tp
.
add_task_by_value
([
fun
,
prom
]()
{
{
try
try
{
{
impl
::
call_prom_set_value
(
*
prom
,
*
fun
,
impl
::
selector
<
typename
std
::
result_of
<
Function
(
Args
...)
>::
type
>
());
impl
::
call_prom_set_value
(
*
prom
,
*
fun
,
impl
::
selector
<
typename
impl
::
result_of
<
Function
(
Args
...)
>::
type
>
());
}
}
catch
(...)
catch
(...)
{
{
...
@@ -82,7 +95,7 @@ namespace dlib
...
@@ -82,7 +95,7 @@ namespace dlib
typename
Function
,
typename
Function
,
typename
...
Args
typename
...
Args
>
>
std
::
future
<
typename
std
::
result_of
<
Function
(
Args
...)
>::
type
>
async
(
std
::
future
<
typename
impl
::
result_of
<
Function
(
Args
...)
>::
type
>
async
(
Function
&&
f
,
Function
&&
f
,
Args
&&
...
args
Args
&&
...
args
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment