STK++ 0.9.13
STK_IRecursiveTemplate.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23 */
24
25/*
26 * Project: stkpp::Sdk
27 * created on: 7 août 2011
28 * Purpose: Create an interface base class for class using the Recursive
29 * template paradigm.
30 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
31 *
32 **/
33
38#ifndef STK_IRECURSIVETEMPLATE_H
39#define STK_IRECURSIVETEMPLATE_H
40
41namespace STK
42{
43
54template<class Derived>
56{
57 protected:
62
63 public:
68 inline Derived& asDerived()
69 { return static_cast<Derived&>(*this); }
74 inline Derived const& asDerived() const
75 { return static_cast<Derived const&>(*this); }
80 inline Derived* asPtrDerived()
81 { return static_cast<Derived*>(this); }
86 inline Derived const* asPtrDerived() const
87 { return static_cast<Derived const*>(this); }
91 inline Derived* clone() const
92 { return new Derived(this->asDerived());}
99 inline Derived* clone(bool isRef) const
100 { return new Derived(this->asDerived(), isRef);}
101};
102
103} // namespace STK
104
105#endif /* STK_IRECURSIVETEMPLATE_H */
Interface base class for all classes implementing the curious recursive template paradigm.
Derived * clone(bool isRef) const
create a leaf using the copy constructor of the Derived class and a flag determining if the clone is ...
Derived * clone() const
create a leaf using the copy constructor of the Derived class.
Derived const * asPtrDerived() const
static cast : return a ptr on a constant Derived of this with a cast to the derived class.
Derived * asPtrDerived()
static cast : return a ptr on a Derived of this with a cast to the derived class.
Derived & asDerived()
static cast : return a reference of this with a cast to the derived class.
Derived const & asDerived() const
static cast : return a const reference of this with a cast to the derived class.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
The namespace STK is the main domain space of the Statistical ToolKit project.