forked from Snapchat/djinni
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Snapchat#166 from jb-gcx/gcx/use-std-expected
Use std::expected for outcome when available
- Loading branch information
Showing
2 changed files
with
32 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,43 @@ | ||
#pragma once | ||
|
||
#ifdef __has_include | ||
#if __has_include(<version>) | ||
#include <version> | ||
#endif | ||
#endif | ||
|
||
#include <utility> | ||
#include <type_traits> | ||
|
||
#ifdef __cpp_lib_expected | ||
|
||
#include <expected> | ||
|
||
namespace djinni { | ||
|
||
using ::std::expected; | ||
using ::std::unexpected; | ||
|
||
} | ||
|
||
#else | ||
|
||
#include "tl_expected.hpp" | ||
|
||
namespace djinni { | ||
|
||
using ::tl::unexpected; | ||
using ::tl::expected; | ||
|
||
} | ||
|
||
#endif | ||
|
||
namespace djinni { | ||
|
||
template <class E> | ||
unexpected<typename std::decay<E>::type> make_unexpected(E &&e) { | ||
return tl::unexpected<typename std::decay<E>::type>(std::forward<E>(e)); | ||
djinni::unexpected<typename std::decay<E>::type> make_unexpected(E &&e) { | ||
return djinni::unexpected<typename std::decay<E>::type>(std::forward<E>(e)); | ||
} | ||
|
||
} |