로딩중...
검색중...
일치하는것 없음
by::tmay< T > 클래스 템플릿 참조

Optional value wrapper for error indication without exceptions 더 자세히 ...

#include <tmay.hpp>

by::tmay< T >에 대한 상속 다이어그램 :
by::tres< T, R >

Public 멤버 함수

 tmay (const T &value)
 
 tmay (const tmedium< T > &value)
 
T * operator-> ()
 
const T * operator-> () const BY_CONST_FUNC(operator->())
 
T & operator* ()
 
const T & operator* () const BY_CONST_FUNC(operator*())
 
 operator T& ()
 
 operator const T & () const
 
 operator nbool () const
 
nbool has () const
 
T * get ()
 Gets the contained value.
 
const T * get () const BY_CONST_FUNC(get()) virtual void rel()
 Releases/clears the contained value, making the instance empty.
 
virtual void set (const T &arg)
 

상세한 설명

template<typename T>
class by::tmay< T >

Optional value wrapper for error indication without exceptions

Provides a way to indicate errors in return-by-value functions without using slow exceptions. Functionally almost identical to std::optional<T>, but with API naming adapted to byeol project conventions.

For normal operation, pass the value as T& to the constructor. For error situations, pass a tmedium class created as nullptr.

Remarks
Why use tmedium? See tmedium for details on why this intermediate type is used.
Common naming conventions The functions has(), get(), rel(), and set() follow naming conventions used throughout the entire project.

Usage

Example of using tmay for error handling:

tmay<std::string> loadConfig(const std::string& path) {
if(!fileExists(path))
return tmay<std::string>(); // Return empty for error
std::string content = readFile(path);
return tmay<std::string>(content); // Return value for success
}
auto config = loadConfig("config.txt");
if(config.has()) {
std::string& value = config.get();
processConfig(value);
}
Rich logging support with polymorphic type conversion
Definition richLog.hpp:34
참고
Use tstr<T> or tweak<T> for return-by-reference cases

멤버 함수 문서화

◆ get()

template<typename T >
T * by::tmay< T >::get ( )

Gets the contained value.

경고
Calling get() on an empty tmay instance results in undefined behavior. It is recommended to check with has() before calling this.
반환값
Pointer to the contained value.

◆ set()

template<typename T >
virtual void by::tmay< T >::set ( const T & arg)
virtual

by::tres< T, R >에서 재구현되었습니다.


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: