cart-elc

Source code for CART-ELC
git clone git://git.laack.co/cart-elc.git
Log | Files | Refs | README | LICENSE

MovableScalar.h (1079B)


      1 // This file is part of Eigen, a lightweight C++ template library
      2 // for linear algebra.
      3 //
      4 // Copyright (C) 2020 Sebastien Boisvert <seb@boisvert.info>
      5 //
      6 // This Source Code Form is subject to the terms of the Mozilla
      7 // Public License v. 2.0. If a copy of the MPL was not distributed
      8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
      9 
     10 #ifndef EIGEN_MISC_MOVABLE_SCALAR_H
     11 #define EIGEN_MISC_MOVABLE_SCALAR_H
     12 
     13 #include <vector>
     14 
     15 namespace Eigen
     16 {
     17 template <typename Scalar, typename Base = std::vector<Scalar>>
     18 struct MovableScalar : public Base
     19 {
     20   MovableScalar() = default;
     21   ~MovableScalar() = default;
     22   MovableScalar(const MovableScalar&) = default;
     23   MovableScalar(MovableScalar&& other) = default;
     24   MovableScalar& operator=(const MovableScalar&) = default;
     25   MovableScalar& operator=(MovableScalar&& other) = default;
     26   MovableScalar(Scalar scalar) : Base(100, scalar) {}
     27 
     28   operator Scalar() const { return this->size() > 0 ? this->back() : Scalar(); }
     29 };
     30 
     31 template<> struct NumTraits<MovableScalar<float>> : GenericNumTraits<float> {};
     32 }
     33 
     34 #endif
     35