From ed38fd0491ee41aa36fc1ce2707299998e07f985 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 15 Apr 2015 14:29:43 +1000 Subject: [PATCH] sphere: check radius is positive at construction --- sphere.cpp | 10 ++++++++++ sphere.hpp | 3 +++ 2 files changed, 13 insertions(+) diff --git a/sphere.cpp b/sphere.cpp index 4419219a..827fc546 100644 --- a/sphere.cpp +++ b/sphere.cpp @@ -19,4 +19,14 @@ using util::sphere; //----------------------------------------------------------------------------- +template +sphere::sphere (point _centre, T _radius): + centre (_centre), + radius (_radius) +{ + CHECK_GE (_radius, 0); +} + +//----------------------------------------------------------------------------- +template struct util::sphere<2,float>; template struct util::sphere<3,float>; diff --git a/sphere.hpp b/sphere.hpp index 7fb965e5..2896d64d 100644 --- a/sphere.hpp +++ b/sphere.hpp @@ -22,10 +22,13 @@ namespace util { template struct sphere { + sphere (point centre, T radius); + point centre; T radius; }; + typedef sphere<2,float> sphere2f; typedef sphere<3,float> sphere3f; }