From b923110b3a6583857f73e2476f6461fed26ddecf Mon Sep 17 00:00:00 2001 From: bangerth Date: Thu, 19 Oct 2006 02:04:55 +0000 Subject: [PATCH] Fix a problem where we can not forward declare an overloaded version of a template function, but nevertheless call the overload from the driver file. This is invalid code according to the standard, but for some reason we have gotten lucky so far... git-svn-id: https://svn.dealii.org/trunk@14026 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/data_out_faces_01.cc | 22 +++++++++++++++++++--- tests/bits/data_out_faces_02.cc | 24 +++++++++++++++++++++--- tests/bits/data_out_faces_03.cc | 24 +++++++++++++++++++++--- tests/bits/data_out_rotation_01.cc | 20 ++++++++++++++++++-- tests/bits/data_out_rotation_02.cc | 22 +++++++++++++++++++--- tests/bits/data_out_rotation_03.cc | 22 +++++++++++++++++++--- tests/bits/dof_tools_18a.cc | 22 +++++++++++++++++++--- tests/bits/dof_tools_18b.cc | 21 ++++++++++++++++++--- tests/bits/dof_tools_18c.cc | 22 +++++++++++++++++++--- tests/bits/dof_tools_18d.cc | 21 ++++++++++++++++++--- 10 files changed, 191 insertions(+), 29 deletions(-) diff --git a/tests/bits/data_out_faces_01.cc b/tests/bits/data_out_faces_01.cc index fdb3b4b611..0b11cc9a45 100644 --- a/tests/bits/data_out_faces_01.cc +++ b/tests/bits/data_out_faces_01.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004 by the deal.II authors +// Copyright (C) 2003, 2004, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -22,7 +22,7 @@ std::string output_file_name = "data_out_faces_01/output"; void -check_this (const DoFHandler<1> &, +my_check_this (const DoFHandler<1> &, const Vector &, const Vector &) { @@ -32,7 +32,7 @@ check_this (const DoFHandler<1> &, template void -check_this (const DoFHandler &dof_handler, +my_check_this (const DoFHandler &dof_handler, const Vector &v_node, const Vector &v_cell) { @@ -55,3 +55,19 @@ check_this (const DoFHandler &dof_handler, } +template +void +check_this (const DoFHandler &dof_handler, + const Vector &v_node, + const Vector &v_cell) +{ + // since we can't forward declare + // check_this in this file (it is forward + // declared in data_out_common.cc), we + // also can't make the driver file aware of + // the overload for 1d. to avoid linker + // errors, we can consequently not overload + // check_this, and need this forwarder + // function + my_check_this (dof_handler, v_node, v_cell); +} diff --git a/tests/bits/data_out_faces_02.cc b/tests/bits/data_out_faces_02.cc index 22f5b3137f..f78399a651 100644 --- a/tests/bits/data_out_faces_02.cc +++ b/tests/bits/data_out_faces_02.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004 by the deal.II authors +// Copyright (C) 2003, 2004, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -24,7 +24,7 @@ std::string output_file_name = "data_out_faces_02/output"; void -check_this (const DoFHandler<1> &, +my_check_this (const DoFHandler<1> &, const Vector &, const Vector &) { @@ -34,7 +34,7 @@ check_this (const DoFHandler<1> &, template void -check_this (const DoFHandler &dof_handler, +my_check_this (const DoFHandler &dof_handler, const Vector &v_node_x, const Vector &v_cell_x) { @@ -61,3 +61,21 @@ check_this (const DoFHandler &dof_handler, } + + +template +void +check_this (const DoFHandler &dof_handler, + const Vector &v_node, + const Vector &v_cell) +{ + // since we can't forward declare + // check_this in this file (it is forward + // declared in data_out_common.cc), we + // also can't make the driver file aware of + // the overload for 1d. to avoid linker + // errors, we can consequently not overload + // check_this, and need this forwarder + // function + my_check_this (dof_handler, v_node, v_cell); +} diff --git a/tests/bits/data_out_faces_03.cc b/tests/bits/data_out_faces_03.cc index 276e26ce53..e3ec61306d 100644 --- a/tests/bits/data_out_faces_03.cc +++ b/tests/bits/data_out_faces_03.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004 by the deal.II authors +// Copyright (C) 2003, 2004, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -57,7 +57,7 @@ class XDataOutReader : public DataOutReader void -check_this (const DoFHandler<1> &, +my_check_this (const DoFHandler<1> &, const Vector &, const Vector &) { @@ -69,7 +69,7 @@ check_this (const DoFHandler<1> &, template void -check_this (const DoFHandler &dof_handler, +my_check_this (const DoFHandler &dof_handler, const Vector &v_node, const Vector &v_cell) { @@ -110,3 +110,21 @@ check_this (const DoFHandler &dof_handler, } + + +template +void +check_this (const DoFHandler &dof_handler, + const Vector &v_node, + const Vector &v_cell) +{ + // since we can't forward declare + // check_this in this file (it is forward + // declared in data_out_common.cc), we + // also can't make the driver file aware of + // the overload for 1d. to avoid linker + // errors, we can consequently not overload + // check_this, and need this forwarder + // function + my_check_this (dof_handler, v_node, v_cell); +} diff --git a/tests/bits/data_out_rotation_01.cc b/tests/bits/data_out_rotation_01.cc index 0b25628098..c6546e791a 100644 --- a/tests/bits/data_out_rotation_01.cc +++ b/tests/bits/data_out_rotation_01.cc @@ -22,7 +22,7 @@ std::string output_file_name = "data_out_rotation_01/output"; void -check_this (const DoFHandler<3> &, +my_check_this (const DoFHandler<3> &, const Vector &, const Vector &) { @@ -32,7 +32,7 @@ check_this (const DoFHandler<3> &, template void -check_this (const DoFHandler &dof_handler, +my_check_this (const DoFHandler &dof_handler, const Vector &v_node, const Vector &v_cell) { @@ -60,3 +60,19 @@ check_this (const DoFHandler &dof_handler, } +template +void +check_this (const DoFHandler &dof_handler, + const Vector &v_node, + const Vector &v_cell) +{ + // since we can't forward declare + // check_this in this file (it is forward + // declared in data_out_common.cc), we + // also can't make the driver file aware of + // the overload for 1d. to avoid linker + // errors, we can consequently not overload + // check_this, and need this forwarder + // function + my_check_this (dof_handler, v_node, v_cell); +} diff --git a/tests/bits/data_out_rotation_02.cc b/tests/bits/data_out_rotation_02.cc index 50a07c906f..2d25af25d2 100644 --- a/tests/bits/data_out_rotation_02.cc +++ b/tests/bits/data_out_rotation_02.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004 by the deal.II authors +// Copyright (C) 2003, 2004, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -25,7 +25,7 @@ std::string output_file_name = "data_out_rotation_02/output"; void -check_this (const DoFHandler<3> &, +my_check_this (const DoFHandler<3> &, const Vector &, const Vector &) { @@ -35,7 +35,7 @@ check_this (const DoFHandler<3> &, template void -check_this (const DoFHandler &dof_handler, +my_check_this (const DoFHandler &dof_handler, const Vector &v_node_x, const Vector &v_cell_x) { @@ -67,3 +67,19 @@ check_this (const DoFHandler &dof_handler, } +template +void +check_this (const DoFHandler &dof_handler, + const Vector &v_node, + const Vector &v_cell) +{ + // since we can't forward declare + // check_this in this file (it is forward + // declared in data_out_common.cc), we + // also can't make the driver file aware of + // the overload for 1d. to avoid linker + // errors, we can consequently not overload + // check_this, and need this forwarder + // function + my_check_this (dof_handler, v_node, v_cell); +} diff --git a/tests/bits/data_out_rotation_03.cc b/tests/bits/data_out_rotation_03.cc index 75a7830c67..ad335d9241 100644 --- a/tests/bits/data_out_rotation_03.cc +++ b/tests/bits/data_out_rotation_03.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004 by the deal.II authors +// Copyright (C) 2003, 2004, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -56,7 +56,7 @@ class XDataOutReader : public DataOutReader void -check_this (const DoFHandler<3> &, +my_check_this (const DoFHandler<3> &, const Vector &, const Vector &) { @@ -67,7 +67,7 @@ check_this (const DoFHandler<3> &, template void -check_this (const DoFHandler &dof_handler, +my_check_this (const DoFHandler &dof_handler, const Vector &v_node, const Vector &v_cell) { @@ -111,3 +111,19 @@ check_this (const DoFHandler &dof_handler, } +template +void +check_this (const DoFHandler &dof_handler, + const Vector &v_node, + const Vector &v_cell) +{ + // since we can't forward declare + // check_this in this file (it is forward + // declared in data_out_common.cc), we + // also can't make the driver file aware of + // the overload for 1d. to avoid linker + // errors, we can consequently not overload + // check_this, and need this forwarder + // function + my_check_this (dof_handler, v_node, v_cell); +} diff --git a/tests/bits/dof_tools_18a.cc b/tests/bits/dof_tools_18a.cc index 143c8de56f..9b954d09da 100644 --- a/tests/bits/dof_tools_18a.cc +++ b/tests/bits/dof_tools_18a.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -40,13 +40,13 @@ make_masks (const unsigned int n, void -check_this (const DoFHandler<1> &) +my_check_this (const DoFHandler<1> &) {} template void -check_this (const DoFHandler &dof_handler) +my_check_this (const DoFHandler &dof_handler) { Table<2,DoFTools::Coupling> mask_int; Table<2,DoFTools::Coupling> mask_ext; @@ -86,3 +86,19 @@ check_this (const DoFHandler &dof_handler) (sp.row_length(l)>1 ? 1 : 0)]); deallog << hash << std::endl; } + + +template +void +check_this (const DoFHandler &dof_handler) +{ + // since we can't forward declare + // check_this in this file (it is forward + // declared in dof_tools_common.cc), we + // also can't make the driver file aware of + // the overload for 1d. to avoid linker + // errors, we can consequently not overload + // check_this, and need this forwarder + // function + my_check_this (dof_handler); +} diff --git a/tests/bits/dof_tools_18b.cc b/tests/bits/dof_tools_18b.cc index 327fee7334..8f62bf955a 100644 --- a/tests/bits/dof_tools_18b.cc +++ b/tests/bits/dof_tools_18b.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -39,14 +39,14 @@ make_masks (const unsigned int n, void -check_this (const DoFHandler<1> &) +my_check_this (const DoFHandler<1> &) {} template void -check_this (const DoFHandler &dof_handler) +my_check_this (const DoFHandler &dof_handler) { Table<2, DoFTools::Coupling> mask_int; Table<2, DoFTools::Coupling> mask_ext; @@ -81,3 +81,18 @@ check_this (const DoFHandler &dof_handler) hash += l*sp.row_length(l); deallog << hash << std::endl; } + +template +void +check_this (const DoFHandler &dof_handler) +{ + // since we can't forward declare + // check_this in this file (it is forward + // declared in dof_tools_common.cc), we + // also can't make the driver file aware of + // the overload for 1d. to avoid linker + // errors, we can consequently not overload + // check_this, and need this forwarder + // function + my_check_this (dof_handler); +} diff --git a/tests/bits/dof_tools_18c.cc b/tests/bits/dof_tools_18c.cc index 23d1958420..5b10b70c52 100644 --- a/tests/bits/dof_tools_18c.cc +++ b/tests/bits/dof_tools_18c.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -39,13 +39,13 @@ make_masks (const unsigned int n, void -check_this (const DoFHandler<1> &) +my_check_this (const DoFHandler<1> &) {} template void -check_this (const DoFHandler &dof_handler) +my_check_this (const DoFHandler &dof_handler) { // we split up the matrix into // blocks according to the number @@ -115,3 +115,19 @@ check_this (const DoFHandler &dof_handler) } } + + +template +void +check_this (const DoFHandler &dof_handler) +{ + // since we can't forward declare + // check_this in this file (it is forward + // declared in dof_tools_common.cc), we + // also can't make the driver file aware of + // the overload for 1d. to avoid linker + // errors, we can consequently not overload + // check_this, and need this forwarder + // function + my_check_this (dof_handler); +} diff --git a/tests/bits/dof_tools_18d.cc b/tests/bits/dof_tools_18d.cc index 1dd177c428..8bea3e6076 100644 --- a/tests/bits/dof_tools_18d.cc +++ b/tests/bits/dof_tools_18d.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -39,14 +39,14 @@ make_masks (const unsigned int n, void -check_this (const DoFHandler<1> &) +my_check_this (const DoFHandler<1> &) {} template void -check_this (const DoFHandler &dof_handler) +my_check_this (const DoFHandler &dof_handler) { // we split up the matrix into // blocks according to the number @@ -115,3 +115,18 @@ check_this (const DoFHandler &dof_handler) } } + +template +void +check_this (const DoFHandler &dof_handler) +{ + // since we can't forward declare + // check_this in this file (it is forward + // declared in dof_tools_common.cc), we + // also can't make the driver file aware of + // the overload for 1d. to avoid linker + // errors, we can consequently not overload + // check_this, and need this forwarder + // function + my_check_this (dof_handler); +} -- 2.39.5