utils: add Result / Option types
Add some Rust-style Result/Option types, based on TartanLlama's expected, optional classes. There's std::optional of course, but we can't depend on C++17 yet.
This commit is contained in:
26
lib/utils/mu-option.hh
Normal file
26
lib/utils/mu-option.hh
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Created on 2020-11-08 by Dirk-Jan C. Binnema <dbinnema@logitech.com>
|
||||
*
|
||||
* Copyright (c) 2020 Logitech, Inc. All Rights Reserved
|
||||
* This program is a trade secret of LOGITECH, and it is not to be reproduced,
|
||||
* published, disclosed to others, copied, adapted, distributed or displayed
|
||||
* without the prior authorization of LOGITECH.
|
||||
*
|
||||
* Licensee agrees to attach or embed this notice on all copies of the program,
|
||||
* including partial copies or modified versions thereof.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MU_OPTION__
|
||||
#define MU_OPTION__
|
||||
|
||||
#include "optional.hpp"
|
||||
|
||||
|
||||
namespace Mu {
|
||||
|
||||
/// Either a value of type T, or nothing.
|
||||
template <typename T> using Option=tl::optional<T>;
|
||||
|
||||
}
|
||||
#endif /*MU_OPTION__*/
|
||||
Reference in New Issue
Block a user