extent: add contract methods

This commit is contained in:
Danny Robson 2015-04-08 19:00:33 +10:00
parent 5b878983a6
commit af11d7c730
2 changed files with 21 additions and 1 deletions

View File

@ -77,7 +77,25 @@ template <size_t S, typename T>
util::extent<S,T>
util::extent<S,T>::expanded (T t) const
{
return expanded (util::vector<S,T> {t});
return *this + util::vector<S,T> {t};
}
//-----------------------------------------------------------------------------
template <size_t S, typename T>
util::extent<S,T>
util::extent<S,T>::contracted (vector<S,T> t) const
{
return *this - t;
}
//-----------------------------------------------------------------------------
template <size_t S, typename T>
util::extent<S,T>
util::extent<S,T>::contracted (T t) const
{
return *this - vector<S,T> {-t};
}

View File

@ -45,6 +45,8 @@ namespace util {
extent expanded (vector<S,T>) const;
extent expanded (T) const;
extent contracted (vector<S,T>) const;
extent contracted (T) const;
bool empty (void) const;