From bcaa6c7428cafaf4d0666303e7fed070dd893717 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 21 Sep 2015 15:33:58 +1000 Subject: [PATCH] region: add cast function --- Makefile.am | 1 + region.hpp | 6 ++++++ region.ipp | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 region.ipp diff --git a/Makefile.am b/Makefile.am index a39b977f..9e9b9196 100644 --- a/Makefile.am +++ b/Makefile.am @@ -214,6 +214,7 @@ UTIL_FILES = \ ray.hpp \ region.cpp \ region.hpp \ + region.ipp \ si.cpp \ signal.cpp \ signal.hpp \ diff --git a/region.hpp b/region.hpp index 48512805..483357a4 100644 --- a/region.hpp +++ b/region.hpp @@ -67,6 +67,10 @@ namespace util { region (point_t, point_t); explicit region (std::array); + //--------------------------------------------------------------------- + template + constexpr region cast (void) const; + //--------------------------------------------------------------------- size_type area (void) const; size_type diameter (void) const; @@ -133,4 +137,6 @@ namespace util { std::ostream& operator<< (std::ostream&, const util::region&); } +#include "region.ipp" + #endif diff --git a/region.ipp b/region.ipp new file mode 100644 index 00000000..38000f3e --- /dev/null +++ b/region.ipp @@ -0,0 +1,33 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Copyright 2010-2015 Danny Robson + */ + +#ifdef __UTIL_REGION_IPP +#error +#endif +#define __UTIL_REGION_IPP + +namespace util { + template + template + constexpr region + region::cast (void) const + { + return { + p.template cast::position_type> (), + e.template cast::size_type> () + }; + } +}