ned14 / outcome

Provides very lightweight outcome<T> and result<T> (non-Boost edition)
https://ned14.github.io/outcome
Other
675 stars 62 forks source link

msvc 2022 C2027, compilation error #272

Closed basiliscos closed 1 year ago

basiliscos commented 1 year ago

Hi,

When I upgraded my compiler to msvc 2022 and boost to 1.79, I met the following issue:

C:\.conan\5dc67d\1\include\boost\outcome\detail\value_storage.hpp(1452,31): error C2027: use of undefined type 'boost::
outcome_v2::detail::move_assign_to_empty<void,false,false>' [D:\development\windows-service-master\build\example\exampl
e-service.vcxproj]                                                                                                     
C:\.conan\5dc67d\1\include\boost\outcome\detail\value_storage.hpp(1451): message : see declaration of 'boost::outcome_v
2::detail::move_assign_to_empty<void,false,false>' [D:\development\windows-service-master\build\example\example-service
.vcxproj]                                                                                                              
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\optional(272): message : see 
reference to function template instantiation 'void std::_Optional_construct_base<_Ty>::_Assign<_Ty>(_Ty2 &&)' being com
piled [D:\development\windows-service-master\build\example\example-service.vcxproj]                                    
          with                                                                                                         
          [                                                                                                            
              _Ty=windows_service::OperationResult,                                                                    
              _Ty2=windows_service::OperationResult                                                                    
          ]                                                                                                            
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\optional(272): message : see 
reference to function template instantiation 'void std::_Optional_construct_base<_Ty>::_Assign<_Ty>(_Ty2 &&)' being com
piled [D:\development\windows-service-master\build\example\example-service.vcxproj]                                    
          with                                                                                                         
          [                                                                                                            
              _Ty=windows_service::OperationResult,                                                                    
              _Ty2=windows_service::OperationResult                                                                    
          ]                                                                                                            
D:\development\windows-service-master\example\example-service.cpp(91): message : see reference to function template ins
tantiation 'std::optional<windows_service::OperationResult> &std::optional<windows_service::OperationResult>::operator 
=<windows_service::OperationResult,0>(_Ty2 &&)' being compiled [D:\development\windows-service-master\build\example\exa
mple-service.vcxproj]                                                                                                  

Could you, please, advice what can be done? Related code samples:

#include <boost/outcome.hpp>
namespace outcome = BOOST_OUTCOME_V2_NAMESPACE;

template <typename T> using Result = outcome::result<T, std::string>;
using OperationResult = Result<void>;

struct ServiceFront {
  OperationResult install();
};

  ExampleService service(logger, "example-service");
  r = service.install(); // example-service.cpp(91)

Environment details:

-- Selecting Windows SDK version 10.0.19041.0 to target Windows 6.1.7601.
-- The C compiler identification is MSVC 19.31.31107.0
-- The CXX compiler identification is MSVC 19.31.31107.0
Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/HostX64/x64/cl.exe - skipped
-- Found Boost: 1.79.0 (found version "1.79.0")

Thank you!

wbr, basiliscos

ned14 commented 1 year ago

This looks similar to #262 ?

basiliscos commented 1 year ago

I have found, that boost upgrade 1.79 -> 1.80 fixes the problem.

ned14 commented 1 year ago

Great news, thanks for letting us know.