Go to the documentation of this file.
39 #ifndef PrecisionAdaptor_H
40 #define PrecisionAdaptor_H
51 template<
class Type,
class InputType,
template<
class>
class Container =
Field>
54 public refPtr<Container<Type>>
59 void copyInput(
const Container<InputType>&
input)
61 this->
reset(
new Container<Type>(
input.size()));
66 void moveInput(
tmp<Container<InputType>>&
input)
68 if (std::is_same<Type, InputType>::value)
72 if (tinput.is_pointer())
75 this->
reset(tinput.ptr());
80 this->
cref(tinput.cref());
85 this->copyInput(
input.cref());
104 if (std::is_same<Type, InputType>::value)
107 this->
cref(
reinterpret_cast<const FieldType&
>(
input));
111 this->copyInput(
input);
121 this->moveInput(
input);
139 static const Container<Type>&
get
141 const Container<InputType>&
input,
145 if (std::is_same<Type, InputType>::value)
151 dst.resize(
input.size());
152 std::copy(
input.cbegin(),
input.cend(), dst.begin());
160 template<
class Type,
class InputType,
template<
class>
class Container =
Field>
163 public refPtr<Container<Type>>
168 Container<InputType>& ref_;
174 void copyInput(
const Container<InputType>&
input,
const bool copy)
176 this->
reset(
new Container<Type>(
input.size()));
179 std::copy(
input.cbegin(),
input.cend(), this->
ref().begin());
195 refPtr<Container<Type>>(),
198 if (std::is_same<Type, InputType>::value)
201 this->
ref(
reinterpret_cast<FieldType&
>(ref_));
205 this->copyInput(
input, copy);
215 const FieldType& store = this->
cref();
216 ref_.resize(store.size());
217 std::copy(store.cbegin(), store.cend(), ref_.begin());
bool is_pointer() const noexcept
True if this is a managed pointer (not a reference)
A class for managing temporary objects.
Container< Type > * get() noexcept
Return pointer without nullptr checking.
ConstPrecisionAdaptor(tmp< Container< InputType >> &&input)
Construct from tmp Container, copy/move as required.
Generic templated field type.
const Container< Type > & cref() const
~PrecisionAdaptor()
Destructor, copy back on destroy.
A non-const Field/List wrapper with possible data conversion.
void reset(Container< Type > *p=nullptr) noexcept
Delete managed temporary object and set to new given pointer.
Container< Type > FieldType
The adapted field type.
ConstPrecisionAdaptor(const Container< InputType > &input)
Construct from Container<InputType>, copying on input as required.
A const Field/List wrapper with possible data conversion.
static Istream & input(Istream &is, IntRange< T > &range)
Container< Type > FieldType
The adapted field type.
PrecisionAdaptor(Container< InputType > &input, const bool copy=true)
Construct from Container<InputType>, copying on input if required.
Container< Type > & ref() const
ConstPrecisionAdaptor(const tmp< Container< InputType >> &input)
Construct from tmp Container, copy/move as required.
A class for managing references or pointers (no reference counting)