From 950fed7d81707cc075cd705dba785d4b9c177213 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 21 Jul 2015 01:38:36 +1000 Subject: [PATCH] coord: add constexpr constructors --- coord/base.hpp | 4 ++-- coord/init.hpp | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/coord/base.hpp b/coord/base.hpp index 122be4ad..0c910f05 100644 --- a/coord/base.hpp +++ b/coord/base.hpp @@ -39,10 +39,10 @@ namespace util { namespace coord { using init::init; base () = default; - explicit base (T val) + constexpr explicit base (T val) { std::fill (std::begin (this->data), std::end (this->data), val); } - base (const base &rhs) = default; + constexpr base (const base &rhs) = default; base& operator= (const base &rhs) = default; // element accessors diff --git a/coord/init.hpp b/coord/init.hpp index ba312e04..2307b458 100644 --- a/coord/init.hpp +++ b/coord/init.hpp @@ -30,8 +30,8 @@ namespace util { namespace coord { struct init<1,T,tags...> : public store<1,T,tags...> { using store<1,T,tags...>::store; - init () = default; - init (T v0): + constexpr init () = default; + constexpr init (T v0): store<1,T,tags...> ({v0}) { ; } }; @@ -42,8 +42,8 @@ namespace util { namespace coord { struct init<2,T,tags...> : public store<2,T,tags...> { using store<2,T,tags...>::store; - init () = default; - init (T v0, T v1): + constexpr init () = default; + constexpr init (T v0, T v1): store<2,T,tags...> ({ v0, v1 }) { ; } }; @@ -54,8 +54,8 @@ namespace util { namespace coord { struct init<3,T,tags...> : public store<3,T,tags...> { using store<3,T,tags...>::store; - init () = default; - init (T v0, T v1, T v2): + constexpr init () = default; + constexpr init (T v0, T v1, T v2): store<3,T,tags...> ({v0, v1, v2}) { ; } }; @@ -66,8 +66,8 @@ namespace util { namespace coord { struct init<4,T,tags...> : public store<4,T,tags...> { using store<4,T,tags...>::store; - init () = default; - init (T v0, T v1, T v2, T v3): + constexpr init () = default; + constexpr init (T v0, T v1, T v2, T v3): store<4,T,tags...> ({ v0, v1, v2, v3 }) { ; } };