ned14 / status-code

Proposed SG14 status_code for the C++ standard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The worked example of a custom domain does not compile under MSVC 15.8.x

zomgrolf opened this issue · comments

Hi,
I've been looking at this library as a potential replacement for std::error_code and the <system_error> header and it looks very promising. Having said that, I'm having some issues trying to compile the custom domain example included in the docs. After adjusting names of protected virtual member functions to use the _do prefix, I'm still seeing the following error on MSVC (copied verbatim from the Wanbox page, built with /W4 /permissive- and /std:c++latest):

1>d:\libs\status-code-master\include\status_code.hpp(337): error C2102: '&' requires l-value
1>d:\projects\statuscodetest\statuscodetest\main.cpp(204): note: see reference to function template instantiation 'system_error2::status_code<_thrown_exception_domain>::status_code<exception_ptr_storage_t::index_type>(system_error2::in_place_t,exception_ptr_storage_t::index_type &&) noexcept' being compiled
1>d:\projects\statuscodetest\statuscodetest\main.cpp(204): note: see reference to function template instantiation 'system_error2::status_code<_thrown_exception_domain>::status_code<exception_ptr_storage_t::index_type>(system_error2::in_place_t,exception_ptr_storage_t::index_type &&) noexcept' being compiled
1>d:\libs\status-code-master\include\status_code.hpp(337): error C2664: 'system_error2::mixins::mixin<system_error2::detail::status_code_storage<DomainType>,DomainType>::mixin(system_error2::mixins::mixin<system_error2::detail::status_code_storage<DomainType>,DomainType> &&)': cannot convert argument 2 from 'const _thrown_exception_domain **' to 'const system_error2::status_code_domain *'
1>        with
1>        [
1>            DomainType=_thrown_exception_domain
1>        ]
1>d:\libs\status-code-master\include\status_code.hpp(337): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

Any ideas? Removing the address-of operator makes that error go away, but it then fails in a different location (and the reason is the lack of the address-of operator). I'm trying to wrap my head around how this machinery works internally and I'm not yet at the stage, where I can just dive in and diagnose what's gone wrong here :)

Thanks,
Z

Also, rather than it being just an example of writing a custom domain, is there a particular reason why this couldn't be included in the actual library? Looks like something potentially very useful (I'm certainly more likely to use it than, say the domain for representing status codes returned by the NT kernel...)

Firstly, my apologies for missing this issue being opened. Somehow I had become unsubscribed from this repo. Sorry.

The example in https://github.com/ned14/status-code/blob/master/doc/custom_domain_worked_example.md is almost certainly out of date. Are you saying you'd like a finished implementation added to examples/*, and the markdown updated to be correct?

Fixed. Thanks for the bug report.