Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
TrialExpressionBase.h
Go to the documentation of this file.
1/* This file is part of MoDELib, the Mechanics Of Defects Evolution Library.
2 *
3 *
4 * MoDELib is distributed without any warranty under the
5 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6 */
7
8#ifndef model_TrialExpressionBase_H_
9#define model_TrialExpressionBase_H_
10
11#include <memory>
12#include <type_traits>
13#include <iostream>
14#include <iomanip>
15#include <TypeTraits.h>
16#include <TestExpression.h>
17#include <EvalExpression.h>
18
19namespace model
20{
21
22 template<typename Derived>
24 {
28
29 Derived& derived()
30 {
31 return *static_cast<Derived*>(this);
32 }
33
34 Derived* p_derived()
35 {
36 return static_cast<Derived*>(this);
37 }
38
39 const Derived& derived() const
40 {
41 return *static_cast<const Derived*>(this);
42 }
43
44 const Derived* p_derived() const
45 {
46 return static_cast<const Derived*>(this);
47 }
48
49 operator const Derived&() const
50 {
51 return derived();
52 }
53
54 };
55
56
57 template<class T, std::enable_if_t<std::is_base_of_v<TrialExpressionBase<T>,T>,int> = 0>
58 auto test(const std::shared_ptr<T>& t)
59 {
60 return std::make_shared<TestExpression<T>>(t);
61 }
62 template<class T, std::enable_if_t<std::is_base_of_v<TrialExpressionBase<T>,T>,int> = 0>
63 auto eval(const std::shared_ptr<T>& t)
64 {
65 return std::make_shared<EvalExpression<T>>(t);
66 }
67}
68#endif
final point of the source segment t
auto eval(const std::shared_ptr< T > &t)
const Derived & derived() const
const Derived * p_derived() const
TrialExpressionBase(const TrialExpressionBase< Derived > &)=delete
TrialExpressionBase(TrialExpressionBase< Derived > &&)=delete