Add point::redim implementation
This commit is contained in:
parent
db62693535
commit
9cc47a05bd
@ -101,6 +101,7 @@ UTIL_FILES = \
|
|||||||
platform.hpp \
|
platform.hpp \
|
||||||
point.cpp \
|
point.cpp \
|
||||||
point.hpp \
|
point.hpp \
|
||||||
|
point.ipp \
|
||||||
pool.cpp \
|
pool.cpp \
|
||||||
pool.hpp \
|
pool.hpp \
|
||||||
pool.ipp \
|
pool.ipp \
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with libgim. If not, see <http://www.gnu.org/licenses/>.
|
* along with libgim. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* Copyright 2011 Danny Robson <danny@nerdcruft.net>
|
* Copyright 2011-14 Danny Robson <danny@nerdcruft.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __UTIL_POINT_HPP
|
#ifndef __UTIL_POINT_HPP
|
||||||
@ -53,7 +53,7 @@ namespace util {
|
|||||||
|
|
||||||
util::vector<S> to (const point<S>&) const;
|
util::vector<S> to (const point<S>&) const;
|
||||||
|
|
||||||
template <size_t D> point<D> redim (void);
|
template <size_t D> point<D> redim (void) const;
|
||||||
|
|
||||||
void sanity (void) const;
|
void sanity (void) const;
|
||||||
};
|
};
|
||||||
@ -68,6 +68,6 @@ namespace util {
|
|||||||
std::ostream& operator<< (std::ostream&, const util::point<S>&);
|
std::ostream& operator<< (std::ostream&, const util::point<S>&);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "point.ipp"
|
||||||
|
|
||||||
#endif // __UTIL_POINT_HPP
|
#endif // __UTIL_POINT_HPP
|
||||||
|
30
point.ipp
Normal file
30
point.ipp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of libgim.
|
||||||
|
*
|
||||||
|
* libgim is free software: you can redistribute it and/or modify it under the
|
||||||
|
* terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* libgim is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with libgim. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Copyright 2014 Danny Robson <danny@nerdcruft.net>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace util {
|
||||||
|
template<size_t S>
|
||||||
|
template<size_t D>
|
||||||
|
point<D> point<S>::redim (void) const {
|
||||||
|
point<D> out;
|
||||||
|
std::copy (std::begin (this->data), std::begin (this->data) + D, std::begin (out.data));
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@ TEST_BIN = \
|
|||||||
md4 \
|
md4 \
|
||||||
md5 \
|
md5 \
|
||||||
options \
|
options \
|
||||||
|
point \
|
||||||
pool \
|
pool \
|
||||||
rand \
|
rand \
|
||||||
range \
|
range \
|
||||||
|
16
test/point.cpp
Normal file
16
test/point.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
#include "point.hpp"
|
||||||
|
|
||||||
|
#include "debug.hpp"
|
||||||
|
#include "types.hpp"
|
||||||
|
|
||||||
|
using namespace util;
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int, char**) {
|
||||||
|
const point<3> p(0.0, 1.0, 2.0);
|
||||||
|
const point<2> q = p.redim<2> ();
|
||||||
|
|
||||||
|
CHECK_EQ (q.data[0], p.data[0]);
|
||||||
|
CHECK_EQ (q.data[1], p.data[1]);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user