CopyWrapper< T > Class Template Reference

#include <movecopywrapper.h>

详细描述

template<typename T>
class maxon::CopyWrapper< T >

This wrapper helps to capture objects which require CopyFrom() in a lambda. The get method will return an error if copying the object into the wrapper failed. Of course move construction and assignment are supported too.

Template Parameters
T Type of object to wrapped. JobRef EnqueueSendJob( const BaseArray<Char>& jobdata) { return JobRef::Enqueue ( [ this , copy = CopyWrapper <BaseArray<Char>>(jobdata)]() -> Result<void> { iferr_scope ; const BaseArray<Char>& array = copy.Get() iferr_return ; return _stream.Write(array.GetFirst(), array.GetCount()); }, _queue); }

公共成员函数

  CopyWrapper ()
  CopyWrapper (const T & src )
  CopyWrapper (T && src )
  CopyWrapper (const CopyWrapper & src )
  CopyWrapper ( CopyWrapper && src )
CopyWrapper operator= (const CopyWrapper & src )
CopyWrapper operator= ( CopyWrapper && src )
ResultRef < const T >  Get () const
ResultRef < T >  Get ()

Private Attributes

_value
T *  _ptr

构造函数 & 析构函数文档编制

◆  CopyWrapper() [1/5]

CopyWrapper ( )

◆  CopyWrapper() [2/5]

CopyWrapper ( const T &  src )
explicit

Copies the source object into the wrapper. Get() will return an error if the copy failed.

参数
[in] src Object to be copied into the wrapper.

◆  CopyWrapper() [3/5]

CopyWrapper ( T &&  src )
explicit

Moves the source object into the wrapper. Following Get() s will succeed because the move can't fail.

参数
[in] src Object to be moved into the wrapper.

◆  CopyWrapper() [4/5]

CopyWrapper ( const CopyWrapper < T > &  src )

Copies the source wrapper. Get() will return an error if the copy failed.

参数
[in] src Wrapper to be copied.

◆  CopyWrapper() [5/5]

CopyWrapper ( CopyWrapper < T > &&  src )

Moves the source wrapper. Following Get() s will succeed because the move can't fail.

参数
[in] src Wrapper to be moved.

成员函数文档编制

◆  operator=() [1/2]

CopyWrapper & operator= ( const CopyWrapper < T > &  src )

Copy assigns the source wrapper. Get() will return an error if the copy failed.

参数
[in] src Wrapper to be copied.

◆  operator=() [2/2]

CopyWrapper & operator= ( CopyWrapper < T > &&  src )

Move assign the source wrapper. Following Get() s will succeed because the move can't fail.

参数
[in] src Wrapper to be moved.

◆  Get() [1/2]

ResultRef <const T> Get ( ) const

Returns a reference to the wrapped object if the assignment or construction of the wrapper was successful.

返回
Reference to wrapped object on success, error on failure.

◆  Get() [2/2]

ResultRef <T> Get ( )

Returns a reference to the wrapped object if the assignment or construction of the wrapper was successful.

返回
Reference to wrapped object on success, error on failure.

Member Data Documentation

◆  _value

T _value mutable private

◆  _ptr

T* _ptr private
maxon::CopyWrapper::CopyWrapper
CopyWrapper()
定义: movecopywrapper.h:36
iferr_return
#define iferr_return
定义: resultbase.h:1434
iferr_scope
#define iferr_scope
定义: resultbase.h:1343
maxon::JobRef::Enqueue
JobRef & Enqueue(JobQueueInterface *queue=JOBQUEUE_CURRENT)
定义: job.h:1236