From 4fa7789786a499c8425479a07a7993ab00ac3258 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 13 Jun 2012 14:41:53 +1000 Subject: [PATCH] Instantiate templates in their enclosing namespace --- noise/basis.cpp | 22 ++++++++++++++++------ range.cpp | 41 ++++++++++++++++++++++++++++++----------- region.cpp | 17 +++++++++-------- region.hpp | 7 ++++--- 4 files changed, 59 insertions(+), 28 deletions(-) diff --git a/noise/basis.cpp b/noise/basis.cpp index e400e9f2..fd3fcc04 100644 --- a/noise/basis.cpp +++ b/noise/basis.cpp @@ -120,9 +120,14 @@ value::eval (double x, double y) const { y_fac); } -template struct value; -template struct value; -template struct value; + +namespace util { + namespace noise { + template struct value; + template struct value; + template struct value; + } +} /////////////////////////////////////////////////////////////////////////////// @@ -175,9 +180,14 @@ gradient::eval (double x, double y) const { y_fac); } -template struct gradient; -template struct gradient; -template struct gradient; + +namespace util { + namespace noise { + template struct gradient; + template struct gradient; + template struct gradient; + } +} /////////////////////////////////////////////////////////////////////////////// diff --git a/range.cpp b/range.cpp index 284214ac..a07623c5 100644 --- a/range.cpp +++ b/range.cpp @@ -1,3 +1,23 @@ +/* + * 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 2011-2012 Danny Robson + */ + + #include "range.hpp" #include "debug.hpp" @@ -7,15 +27,12 @@ #include +//----------------------------------------------------------------------------- using namespace std; using namespace util; -/* - * Range - */ - - +//----------------------------------------------------------------------------- template range::range (const json::node &node) { if (node.is_string () && (node == "UNIT" || @@ -170,9 +187,11 @@ const range range::UNIT (0.0, 1.0); -template struct range; -template struct range; -template struct range; -template struct range; -template struct range; -template struct range; +namespace util { + template struct range; + template struct range; + template struct range; + template struct range; + template struct range; + template struct range; +} diff --git a/region.cpp b/region.cpp index 51485126..16af1ed7 100644 --- a/region.cpp +++ b/region.cpp @@ -163,12 +163,13 @@ operator<< (std::ostream &os, const region &rhs) { } -template struct region; -template struct region; -template struct region; -template struct region; -template struct region; - -template std::ostream& operator<< (std::ostream&, const region&); -template std::ostream& operator<< (std::ostream&, const region&); +namespace util { + template struct region; + template struct region; + template struct region; + template struct region; + template struct region; + template std::ostream& operator<< (std::ostream&, const region&); + template std::ostream& operator<< (std::ostream&, const region&); +} diff --git a/region.hpp b/region.hpp index 81b6b759..398d034b 100644 --- a/region.hpp +++ b/region.hpp @@ -60,10 +60,11 @@ namespace util { void sanity (void) const; }; + + + template + std::ostream& operator<< (std::ostream&, const util::region&); } -template -std::ostream& -operator<< (std::ostream&, const util::region&); #endif