SUNphi  1.0
Assign.hpp File Reference

Defines a class which assigns rhs SmET to lhs one. More...

#include <ios/Logger.hpp>
#include <smet/BinarySmET.hpp>
#include <smet/Reference.hpp>
#include <smet/ScalarWrap.hpp>

Go to the source code of this file.

Classes

struct  SUNphi::BaseAssigner
 
struct  SUNphi::ConstrainAreAssigners< Args >
 
class  SUNphi::Assigner< _Ref1, _Ref2, TK1, TK2 >
 Class to assign a SmET to another one. More...
 

Macros

#define PROVIDE_SMET_ASSIGNEMENT_OPERATOR(UNARY_SMET)
 Defines the assignement operator, calling assign. More...
 
#define PROVIDE_CONST_OR_NOT_DEFAULT_EVALUATOR(QUALIFIER)
 Provides either the const or non-const evaluator. More...
 

Typedefs

template<typename T , typename Ret = void>
using SUNphi::EnableIfIsAssigner = EnableIf< isAssigner< T >,Ret >
 
template<typename T >
using SUNphi::ConstrainIsAssigner = ConstrainIsBaseOf< BaseAssigner,T >
 
template<typename T >
using SUNphi::ConstrainIsNotAssigner = ConstrainIsNotBaseOf< BaseAssigner,T >
 

Functions

template<typename Lhs , typename Rhs >
void SUNphi::assign (Lhs &&lhs, Rhs &&rhs, DummyTypes...)
 

Variables

template<typename T >
constexpr bool SUNphi::isAssigner = isBaseOf<BaseAssigner ,T>
 

Detailed Description

Defines a class which assigns rhs SmET to lhs one.

These are the steps:

  • The call to A=B, with A being a SmET, is intercepted. If A is not assignable an exception is issued. This step is performed in each individual SmET, because operator= must be a static member function. The function assign(A,B) is called.
  • All call to assign where B is not a SmET are intercepted. If B fundamental type is of a type that can be cast to the fundamental type of A, then we return A=scalar(B). Otherwise an exception is issued.
  • If B does not contain all components of A, an exception is issued.
  • Preliminary manipulation is performed, allowing to specific pattern recognition, obtained by overloading assign and using appropriate SFINAE mechanism.
  • The default assign function is called, which returns the rhs as expected allowing to perform chain assignement on the expected return.
  • The Assigner is created inside assign.
  • If the Assigner has mergeable components, they are merged.
  • If the innermost component is vectorizable, it is vectorized.
  • The execution of the assigner is dispatched to the thread pool.

Definition in file Assign.hpp.

Macro Definition Documentation

#define PROVIDE_CONST_OR_NOT_DEFAULT_EVALUATOR (   QUALIFIER)
Value:
\
template <typename...Args> /* Type of the arguments */ \
DECLAUTO eval(const Args&...args) \
QUALIFIER \
{ \
STATIC_ASSERT_ARE_N_TYPES(Tk::nTypes,args); \
\
return ref2.eval(forw<Args>(args)...); \
}
#define STATIC_ASSERT_ARE_N_TYPES(N, UNEXP_PARPACK)
Static assert if not passing exactly N types.
Definition: TypeTraits.hpp:422
#define DECLAUTO
Short name for decltype(auto)

Provides either the const or non-const evaluator.

Definition at line 111 of file Assign.hpp.

#define PROVIDE_SMET_ASSIGNEMENT_OPERATOR (   UNARY_SMET)
Value:
\
template <typename Oth> /* Other type */ \
DECLAUTO operator=(Oth&& oth) \
{ \
if(0) \
{ \
using namespace std; \
cout<<"Operator=, triggering assignement to "<<this<<" of "<<&oth<<endl; \
} \
assign(*this,forw<Oth>(oth)); \
\
return \
*this; \
}
STL namespace.
#define DECLAUTO
Short name for decltype(auto)

Defines the assignement operator, calling assign.

< Name of the NnarySmET

Definition at line 35 of file Assign.hpp.

Typedef Documentation

template<typename T >
using SUNphi::ConstrainIsAssigner = typedef ConstrainIsBaseOf<BaseAssigner ,T>

Class forcing T to inherits from BaseAssigner

Definition at line 52 of file Assign.hpp.

template<typename T >
using SUNphi::ConstrainIsNotAssigner = typedef ConstrainIsNotBaseOf<BaseAssigner ,T>

Class forcing T not to inherits from BaseAssigner

Definition at line 52 of file Assign.hpp.

template<typename T , typename Ret = void>
using SUNphi::EnableIfIsAssigner = typedef EnableIf< isAssigner <T> ,Ret>

Provides the class itself if T is of the given type

Provides the class itself if T satisfies the condition

Definition at line 52 of file Assign.hpp.

Function Documentation

template<typename Lhs , typename Rhs >
void SUNphi::assign ( Lhs &&  lhs,
Rhs &&  rhs,
DummyTypes...   
)

Default assigner taking only SmET as left argument

Rhs can be a SmET or not, in which case it is wrapped into a Scalar

Parameters
lhsLeft hand side, SmET to act upon
rhsRight hand side

Definition at line 138 of file Assign.hpp.

Variable Documentation

template<typename T >
constexpr bool SUNphi::isAssigner = isBaseOf<BaseAssigner ,T>

Expression which is true if T inherits from BaseAssigner

Definition at line 52 of file Assign.hpp.