grantila / q

A platform-independent promise library for C++, implementing asynchronous continuations.
http://libq.io
Apache License 2.0
193 stars 24 forks source link

C++17 Support? #17

Closed Aetf closed 6 years ago

Aetf commented 7 years ago

I want to use C++17 in my own code. But I can't link to q since q is compiled with C++11/14, and there's ABI changes in C++17 due to noexcept being part of the function signature.

I tried to use -DCMAKE_CXX_STANDARD=17 to force C++17, but I'm getting mysterious template errors.

/tmp/workspace/q/libs/q/src/blocking_dispatcher.cpp: In member function 'virtual void q::blocking_dispatcher::start()':
/tmp/workspace/q/libs/q/src/blocking_dispatcher.cpp:95:6: error: second operand to the conditional operator is of type 'void', but the third operand is neither a throw-expression nor of type 'void'
    : timer_task( );
      ^~~~~~~~~~~~~
In file included from /tmp/workspace/q/libs/q/include/q/types.hpp:21:0,
                 from /tmp/workspace/q/libs/q/include/q/event_dispatcher.hpp:20,
                 from /tmp/workspace/q/libs/q/include/q/blocking_dispatcher.hpp:20,
                 from /tmp/workspace/q/libs/q/src/blocking_dispatcher.cpp:2:
/tmp/workspace/q/libs/q/include/q/function.hpp: In instantiation of 'Ret q::detail::any_function<Signature, Shared, TotalSize, Ret, Args>::operator()(Args ...) [with Signature = q::timer_task() noexcept; Shared = std::integral_constant<bool, true>; TotalSize = std::integral_constant<long unsigned int, 128>; Ret = void; Args = {}]':
/tmp/workspace/q/libs/q/src/blocking_dispatcher.cpp:94:29:   required from here
/tmp/workspace/q/libs/q/include/q/function.hpp:812:54: error: return-statement with a value, in function returning 'void' [-fpermissive]
    return ( *sig_ )( std::forward< Args >( args )... );
                                                      ^
make[2]: *** [libs/q/CMakeFiles/q.dir/build.make:111: libs/q/CMakeFiles/q.dir/src/blocking_dispatcher.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:86: libs/q/CMakeFiles/q.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

My compiler is gcc 7.2.0

nholthaus commented 6 years ago

Second this.

nholthaus commented 6 years ago

I've submitted PR #24 to address this issue.

grantila commented 6 years ago

Slightly tweaked #24 and merged to master