From ccbae2dcb1bc776435c68f36c7563825f4e02348 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 13 Jan 2015 18:30:10 +1100 Subject: [PATCH] extent: add typecasting member function --- Makefile.am | 1 + extent.hpp | 5 +++++ extent.ipp | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 extent.ipp diff --git a/Makefile.am b/Makefile.am index 497f0e7b..17a40038 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,6 +27,7 @@ UTIL_FILES = \ exe.hpp \ extent.cpp \ extent.hpp \ + extent.ipp \ fixed.cpp \ fixed.hpp \ float.cpp \ diff --git a/extent.hpp b/extent.hpp index 6e33e5a0..e36e75f8 100644 --- a/extent.hpp +++ b/extent.hpp @@ -45,6 +45,9 @@ namespace util { bool operator !=(const extent& rhs) const { return !(*this == rhs); } + template + extent cast (void) const; + void sanity (void) const; }; } @@ -52,4 +55,6 @@ namespace util { template std::ostream& operator<< (std::ostream&, util::extent); +#include "extent.ipp" + #endif diff --git a/extent.ipp b/extent.ipp new file mode 100644 index 00000000..ac91d88d --- /dev/null +++ b/extent.ipp @@ -0,0 +1,37 @@ +/* + * 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 . + * + * Copyright 2015 Danny Robson + */ + + +#ifdef __UTIL_EXTENT_IPP +#error "twice included ipp" +#endif + +#define __UTIL_EXTENT_IPP + +//----------------------------------------------------------------------------- +template +template +util::extent +util::extent::cast (void) const +{ + return { + static_cast (w), + static_cast (h) + }; +}