Ginkgo  Generated from pipelines/150876808 branch based on develop. Ginkgo version 1.1.1
A numerical linear algebra library targeting many-core architectures
Public Types | Public Member Functions | List of all members
gko::ConvertibleTo< ResultType > Class Template Referenceabstract

ConvertibleTo interface is used to mark that the implementer can be converted to the object of ResultType. More...

#include <ginkgo/core/base/polymorphic_object.hpp>

Public Types

using result_type = ResultType
 

Public Member Functions

virtual void convert_to (result_type *result) const =0
 Converts the implementer to an object of type result_type. More...
 
virtual void move_to (result_type *result)=0
 Converts the implementer to an object of type result_type by moving data from this object. More...
 

Detailed Description

template<typename ResultType>
class gko::ConvertibleTo< ResultType >

ConvertibleTo interface is used to mark that the implementer can be converted to the object of ResultType.

This interface is used to enable conversions between polymorphic objects. To mark that an object of type U can be converted to an object of type V, U should implement ConvertibleTo<V>. Then, the implementation of PolymorphicObject::copy_from automatically generated by EnablePolymorphicObject mixin will use RTTI to figure out that U implements the interface and convert it using the convert_to / move_to methods of the interface.

As an example, the following function:

{c++}
void my_function(const U *u, V *v) {
v->copy_from(u);
}

will convert object u to object v by checking that u can be dynamically casted to ConvertibleTo\<V\>, and calling ConvertibleTo<V>::convert_to(V*)` to do the actual conversion.

In case u is passed as a unique_ptr, call to convert_to will be replaced by a call to move_to and trigger move semantics.

Template Parameters
ResultTypethe type to which the implementer can be converted to, has to be a subclass of PolymorphicObject

Member Function Documentation

◆ convert_to()

template<typename ResultType>
virtual void gko::ConvertibleTo< ResultType >::convert_to ( result_type *  result) const
pure virtual

Converts the implementer to an object of type result_type.

Parameters
resultthe object used to store the result of the conversion

Implemented in gko::EnablePolymorphicAssignment< ConcreteType, ResultType >, gko::EnablePolymorphicAssignment< Isai< IsaiType, ValueType, IndexType > >, gko::EnablePolymorphicAssignment< SparsityCsr< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Dense< ValueType > >, gko::EnablePolymorphicAssignment< UpperTrs< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Hybrid< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Identity< ValueType > >, gko::EnablePolymorphicAssignment< ConcreteLinOp >, gko::EnablePolymorphicAssignment< Composition< ValueType > >, gko::EnablePolymorphicAssignment< Bicgstab< ValueType > >, gko::EnablePolymorphicAssignment< LowerTrs< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Combination< ValueType > >, gko::EnablePolymorphicAssignment< Gmres< ValueType > >, gko::EnablePolymorphicAssignment< Csr< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Ir< ValueType > >, gko::EnablePolymorphicAssignment< Coo< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Fcg< ValueType > >, gko::EnablePolymorphicAssignment< ConcreteFactory >, gko::EnablePolymorphicAssignment< Cgs< ValueType > >, gko::EnablePolymorphicAssignment< Ell< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Ilu< LSolverType, USolverType, ReverseApply, IndexType > >, gko::EnablePolymorphicAssignment< Permutation< IndexType > >, gko::EnablePolymorphicAssignment< Jacobi< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Cg< ValueType > >, gko::EnablePolymorphicAssignment< Sellp< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Bicg< ValueType > >, gko::EnablePolymorphicAssignment< Perturbation< ValueType > >, and gko::preconditioner::Jacobi< ValueType, IndexType >.

◆ move_to()

template<typename ResultType>
virtual void gko::ConvertibleTo< ResultType >::move_to ( result_type *  result)
pure virtual

Converts the implementer to an object of type result_type by moving data from this object.

This method is used when the implementer is a temporary object, and move semantics can be used.

Parameters
resultthe object used to emplace the result of the conversion
Note
ConvertibleTo::move_to can be implemented by simply calling ConvertibleTo::convert_to. However, this operation can often be optimized by exploiting the fact that implementer's data can be moved to the result.

Implemented in gko::EnablePolymorphicAssignment< ConcreteType, ResultType >, gko::EnablePolymorphicAssignment< Isai< IsaiType, ValueType, IndexType > >, gko::EnablePolymorphicAssignment< SparsityCsr< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Dense< ValueType > >, gko::EnablePolymorphicAssignment< UpperTrs< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Hybrid< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Identity< ValueType > >, gko::EnablePolymorphicAssignment< ConcreteLinOp >, gko::EnablePolymorphicAssignment< Composition< ValueType > >, gko::EnablePolymorphicAssignment< Bicgstab< ValueType > >, gko::EnablePolymorphicAssignment< LowerTrs< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Combination< ValueType > >, gko::EnablePolymorphicAssignment< Gmres< ValueType > >, gko::EnablePolymorphicAssignment< Csr< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Ir< ValueType > >, gko::EnablePolymorphicAssignment< Coo< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Fcg< ValueType > >, gko::EnablePolymorphicAssignment< ConcreteFactory >, gko::EnablePolymorphicAssignment< Cgs< ValueType > >, gko::EnablePolymorphicAssignment< Ell< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Ilu< LSolverType, USolverType, ReverseApply, IndexType > >, gko::EnablePolymorphicAssignment< Permutation< IndexType > >, gko::EnablePolymorphicAssignment< Jacobi< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Cg< ValueType > >, gko::EnablePolymorphicAssignment< Sellp< ValueType, IndexType > >, gko::EnablePolymorphicAssignment< Bicg< ValueType > >, gko::EnablePolymorphicAssignment< Perturbation< ValueType > >, and gko::preconditioner::Jacobi< ValueType, IndexType >.


The documentation for this class was generated from the following file: