MeshLib
 
Loading...
Searching...
No Matches
MRExpected.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4
5#include <version>
6#if __cpp_lib_expected >= 202211
7#include <expected>
8#else
9#include <tl/expected.hpp>
12#ifdef MR_DOT_NET_BUILD
13namespace std
14{
15template<typename T, typename E>
16class expected : public tl::expected<T, E>
17{
18 using tl::expected<T, E>::expected;
19};
20
21template <class E>
22inline auto unexpected( E &&e )
23{
24 return tl::make_unexpected( std::forward<E>( e ) );
25}
26}
27#endif
28#endif
29
30#include <string>
31
32namespace MR
33{
34
35#if ( __cpp_lib_expected >= 202211 || defined( MR_DOT_NET_BUILD ) )
36
37template<class T, class E = std::string>
38using Expected = std::expected<T, E>;
39
40template <class E>
41inline auto unexpected( E &&e )
42{
43 return std::unexpected( std::forward<E>( e ) );
44}
45
46#else
47
48template<class T, class E = std::string>
49using Expected = tl::expected<T, E>;
50
51template <class E>
52inline auto unexpected( E &&e )
53{
54 return tl::make_unexpected( std::forward<E>( e ) );
55}
56
57#endif
58
61
63inline std::string stringOperationCanceled()
64{
65 return "Operation was canceled";
66}
67
73
74} //namespace MR
Definition MRCameraOrientationPlugin.h:7
std::string stringOperationCanceled()
Common operation canceled line for all.
Definition MRExpected.h:63
tl::expected< T, E > Expected
Definition MRExpected.h:49
auto unexpected(E &&e)
Definition MRExpected.h:52
auto unexpectedOperationCanceled()
Returns Expected error with stringOperationCanceled()
Definition MRExpected.h:69
Expected< void > VoidOrErrStr
return type for a void function that can produce an error string
Definition MRExpected.h:60