MeshLib C++ Docs
Loading...
Searching...
No Matches
MRExpected.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include "MRPch/MRBindingMacros.h"
5#include "MRPch/MRExpected.h"
6#include <string>
7
8namespace MR
9{
10
11#if MR_USE_STD_EXPECTED || defined(MR_DOT_NET_BUILD)
12
13template<class T, class E = std::string>
14using Expected = std::expected<T, E>;
15
16template <class E>
17MR_BIND_IGNORE inline auto unexpected( E &&e )
18{
19 return std::unexpected( std::forward<E>( e ) );
20}
21
22#else
23
24template<class T, class E = std::string>
25using Expected = tl::expected<T, E>;
26
27template <class E>
28MR_BIND_IGNORE inline auto unexpected( E &&e )
29{
30 return tl::make_unexpected( std::forward<E>( e ) );
31}
32
33#endif
34
37{
38 return "Operation was canceled";
39}
40
46
49{
50 return "Unsupported file extension";
51}
52
58
60#define MR_RETURN_IF_UNEXPECTED( expr ) \
61 if ( auto&& res = ( expr ); !res ) \
62 return unexpected( std::move( res.error() ) );
63
64} //namespace MR
Definition MRCameraOrientationPlugin.h:8
MR_BIND_IGNORE std::string stringUnsupportedFileExtension()
common message about unknown file extension
Definition MRExpected.h:48
MR_BIND_IGNORE auto unexpected(E &&e)
Definition MRExpected.h:28
tl::expected< T, E > Expected
Definition MRExpected.h:25
MR_BIND_IGNORE auto unexpectedUnsupportedFileExtension()
returns Expected error with stringUnsupportedFileExtension()
Definition MRExpected.h:54
MR_BIND_IGNORE auto unexpectedOperationCanceled()
returns Expected error with stringOperationCanceled()
Definition MRExpected.h:42
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:10
MR_BIND_IGNORE std::string stringOperationCanceled()
common message about user termination of an operation
Definition MRExpected.h:36