bezier: add cbegin/cend/begin/end

This commit is contained in:
Danny Robson 2016-03-11 12:43:29 +11:00
parent 191268d38b
commit 92be31d870
2 changed files with 42 additions and 1 deletions

View File

@ -392,8 +392,44 @@ util::bezier<S>::operator[] (size_t idx) const
}
///////////////////////////////////////////////////////////////////////////////
template <size_t S>
const util::point2f*
util::bezier<S>::begin (void) const
{
return std::cbegin (m_points);
}
//-----------------------------------------------------------------------------
template <size_t S>
const util::point2f*
util::bezier<S>::end (void) const
{
return std::cend (m_points);
}
//-----------------------------------------------------------------------------
template <size_t S>
const util::point2f*
util::bezier<S>::cbegin (void) const
{
return std::cbegin (m_points);
}
//-----------------------------------------------------------------------------
template <size_t S>
const util::point2f*
util::bezier<S>::cend (void) const
{
return std::cend (m_points);
}
///////////////////////////////////////////////////////////////////////////////
template <size_t S>
std::ostream&
util::operator<< (std::ostream &os, const bezier<S> &b)
{
@ -405,7 +441,7 @@ util::operator<< (std::ostream &os, const bezier<S> &b)
}
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
#define INSTANTIATE(S) \
template class util::bezier<S>; \
template std::ostream& util::operator<< (std::ostream&, const bezier<S>&);

View File

@ -43,6 +43,11 @@ namespace util {
point2f& operator[] (size_t idx);
const point2f& operator[] (size_t idx) const;
const point2f* begin (void) const;
const point2f* end (void) const;
const point2f* cbegin (void) const;
const point2f* cend (void) const;
private:
// HACK: allow easy access to component-wise arithmetic using
// vector2f rather than point2f in the implementation.