inline capi::DiplomatWriteable WriteableFromString(std::string& string) {
capi::DiplomatWriteable w;
w.context = &string;
w.buf = &string[0];
w.len = string.length(); // Same as length, since C++ strings are not supposed // to be written to past their len; you resize *first*
w.cap = string.length();
w.flush = Flush;
w.grow = Grow; return w;
};
template<class T> struct Ok {
T inner;
Ok(T&& i): inner(std::move(i)) {} // We don't want to expose an lvalue-capable constructor in general // however there is no problem doing this for trivially copyable types template<typename X = T, typename = typename std::enable_if<std::is_trivially_copyable<X>::value>::type>
Ok(T i): inner(i) {}
Ok() = default;
Ok(Ok&&) noexcept = default;
Ok(const Ok &) = default;
Ok& operator=(const Ok&) = default;
Ok& operator=(Ok&&) noexcept = default;
};
template<class T> struct Err {
T inner;
Err(T&& i): inner(std::move(i)) {} // We don't want to expose an lvalue-capable constructor in general // however there is no problem doing this for trivially copyable types template<typename X = T, typename = typename std::enable_if<std::is_trivially_copyable<X>::value>::type>
Err(T i): inner(i) {}
Err() = default;
Err(Err&&) noexcept = default;
Err(const Err &) = default;
Err& operator=(const Err&) = default;
Err& operator=(Err&&) noexcept = default;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.