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

Template result container with typed error information 더 자세히 ...

#include <tres.hpp>

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

Public 멤버 함수

 tres (const T &value)
 
 tres (const R &value)
 
RgetErr ()
 Gets the contained error.
 
const RgetErr () const BY_CONST_FUNC(getErr()) void rel() override
 Releases/clears both the contained value and the error, making the instance empty.
 
void set (const T &arg) override
 Sets the contained value and clears any existing error.
 
void setErr (const R &arg)
 Sets the contained error and clears any existing value.
 
- by::tmay< T >(으)로부터 상속된 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.
 

상세한 설명

template<typename T, typename R>
class by::tres< T, R >

Template result container with typed error information

Identical to tmay but allows defining a custom error type when errors occur. While tmay<T> can only indicate whether an error occurred or not, tres<T, R> can provide detailed error information of type R when an error occurs.

Usage

Example comparing tmay and tres:

// Using tmay - can only tell if error occurred:
if(!result1.has()) {
// Know there's an error, but not what kind
}
// Using tres - can get error details:
if(!result2.has()) {
std::string errorMsg = result2.getErr(); // Get specific error message
BY_E("Parse failed: %s", errorMsg.c_str());
}
#define BY_E(fmt,...)
Log macro: prints debug log on console and file.
Definition macro.hpp:22
Rich logging support with polymorphic type conversion
Definition richLog.hpp:34

Common error types include std::string for error messages, or custom error enums for categorized error handling.

멤버 함수 문서화

◆ getErr()

template<typename T , typename R >
R & by::tres< T, R >::getErr ( )

Gets the contained error.

경고
Should only be called when has() returns false. Accessing when has() is true results in undefined behavior.
반환값
A reference to the contained error object.

◆ set()

template<typename T , typename R >
void by::tres< T, R >::set ( const T & arg)
overridevirtual

Sets the contained value and clears any existing error.

by::tmay< T >(으)로부터 재구현되었습니다.


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