From: Wolfgang Bangerth Date: Thu, 6 Sep 2012 21:02:37 +0000 (+0000) Subject: Make clang++ happy by ensuring that operator== is actually declared in the same names... X-Git-Tag: v8.0.0~2163 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=653656cd10d20dd5a826bc71ab68f294ccc132cc;p=dealii.git Make clang++ happy by ensuring that operator== is actually declared in the same namespace as its arguments (namely, namespace dealii). git-svn-id: https://svn.dealii.org/trunk@26244 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/serialization/dof_handler_01.cc b/tests/serialization/dof_handler_01.cc index 842eff65ef..a3fadf7552 100644 --- a/tests/serialization/dof_handler_01.cc +++ b/tests/serialization/dof_handler_01.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2010, 2011 by the deal.II authors +// Copyright (C) 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -24,101 +24,104 @@ #include #include -template -bool operator == (const DoFHandler &t1, - const DoFHandler &t2) +namespace dealii { - // test a few attributes, though we can't - // test everything unfortunately... - typename DoFHandler::cell_iterator - c1 = t1.begin(), - c2 = t2.begin(); - for (; (c1 != t1.end()) && (c2 != t2.end()); ++c1, ++c2) - { - for (unsigned int v=0; v::vertices_per_cell; ++v) - { - if (c1->vertex(v) != c2->vertex(v)) - return false; - if (c1->vertex_index(v) != c2->vertex_index(v)) - return false; - } - - for (unsigned int f=0; f::faces_per_cell; ++f) - { - if (c1->face(f)->at_boundary() != c2->face(f)->at_boundary()) - return false; - - if (c1->face(f)->at_boundary()) - { - if (c1->face(f)->boundary_indicator() != - c2->face(f)->boundary_indicator()) - return false; - } - else - { - if (c1->neighbor(f)->level() != c2->neighbor(f)->level()) - return false; - if (c1->neighbor(f)->index() != c2->neighbor(f)->index()) - return false; - } - } - - if (c1->subdomain_id() != c2->subdomain_id()) - return false; - - if (c1->material_id() != c2->material_id()) - return false; - - if (c1->user_index() != c2->user_index()) - return false; - - if (c1->user_flag_set() != c2->user_flag_set()) - return false; - - if (c1->get_fe().get_name() != c2->get_fe().get_name()) - return false; - - if (c1->active_fe_index() != c2->active_fe_index()) - return false; - - // compare dofs on this cell and then on the faces - if (c1->has_children() == false) + template + bool operator == (const DoFHandler &t1, + const DoFHandler &t2) + { + // test a few attributes, though we can't + // test everything unfortunately... + typename DoFHandler::cell_iterator + c1 = t1.begin(), + c2 = t2.begin(); + for (; (c1 != t1.end()) && (c2 != t2.end()); ++c1, ++c2) { - std::vector local_dofs_1 (c1->get_fe().dofs_per_cell); - std::vector local_dofs_2 (c2->get_fe().dofs_per_cell); + for (unsigned int v=0; v::vertices_per_cell; ++v) + { + if (c1->vertex(v) != c2->vertex(v)) + return false; + if (c1->vertex_index(v) != c2->vertex_index(v)) + return false; + } + + for (unsigned int f=0; f::faces_per_cell; ++f) + { + if (c1->face(f)->at_boundary() != c2->face(f)->at_boundary()) + return false; + + if (c1->face(f)->at_boundary()) + { + if (c1->face(f)->boundary_indicator() != + c2->face(f)->boundary_indicator()) + return false; + } + else + { + if (c1->neighbor(f)->level() != c2->neighbor(f)->level()) + return false; + if (c1->neighbor(f)->index() != c2->neighbor(f)->index()) + return false; + } + } + + if (c1->subdomain_id() != c2->subdomain_id()) + return false; - c1->get_dof_indices (local_dofs_1); - c2->get_dof_indices (local_dofs_2); - if (local_dofs_1 != local_dofs_2) + if (c1->material_id() != c2->material_id()) return false; - for (unsigned int f=0; f::faces_per_cell; ++f) - { - std::vector local_dofs_1 (c1->get_fe().dofs_per_face); - std::vector local_dofs_2 (c2->get_fe().dofs_per_face); - - c1->face(f)->get_dof_indices (local_dofs_1); - c2->face(f)->get_dof_indices (local_dofs_2); - if (local_dofs_1 != local_dofs_2) - return false; - } + if (c1->user_index() != c2->user_index()) + return false; + + if (c1->user_flag_set() != c2->user_flag_set()) + return false; + + if (c1->get_fe().get_name() != c2->get_fe().get_name()) + return false; + + if (c1->active_fe_index() != c2->active_fe_index()) + return false; + + // compare dofs on this cell and then on the faces + if (c1->has_children() == false) + { + std::vector local_dofs_1 (c1->get_fe().dofs_per_cell); + std::vector local_dofs_2 (c2->get_fe().dofs_per_cell); + + c1->get_dof_indices (local_dofs_1); + c2->get_dof_indices (local_dofs_2); + if (local_dofs_1 != local_dofs_2) + return false; + + for (unsigned int f=0; f::faces_per_cell; ++f) + { + std::vector local_dofs_1 (c1->get_fe().dofs_per_face); + std::vector local_dofs_2 (c2->get_fe().dofs_per_face); + + c1->face(f)->get_dof_indices (local_dofs_1); + c2->face(f)->get_dof_indices (local_dofs_2); + if (local_dofs_1 != local_dofs_2) + return false; + } + } } - } - - // also check the order of raw iterators as they contain - // something about the history of the triangulation - typename DoFHandler::cell_iterator - r1 = t1.begin_raw(), - r2 = t2.begin_raw(); - for (; (r1 != t1.end()) && (r2 != t2.end()); ++r1, ++r2) - { - if (r1->level() != r2->level()) - return false; - if (r1->index() != r2->index()) - return false; - } - return true; + // also check the order of raw iterators as they contain + // something about the history of the triangulation + typename DoFHandler::cell_iterator + r1 = t1.begin_raw(), + r2 = t2.begin_raw(); + for (; (r1 != t1.end()) && (r2 != t2.end()); ++r1, ++r2) + { + if (r1->level() != r2->level()) + return false; + if (r1->index() != r2->index()) + return false; + } + + return true; + } } template diff --git a/tests/serialization/triangulation_01.cc b/tests/serialization/triangulation_01.cc index 7ad05ca620..48c7e1c725 100644 --- a/tests/serialization/triangulation_01.cc +++ b/tests/serialization/triangulation_01.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2010, 2011 by the deal.II authors +// Copyright (C) 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -19,83 +19,87 @@ #include #include -template -bool operator == (const Triangulation &t1, - const Triangulation &t2) +namespace dealii { - // test a few attributes, though we can't - // test everything unfortunately... - if (t1.n_active_cells() != t2.n_active_cells()) - return false; - - if (t1.n_cells() != t2.n_cells()) - return false; - - if (t1.n_faces() != t2.n_faces()) - return false; - - typename Triangulation::cell_iterator - c1 = t1.begin(), - c2 = t2.begin(); - for (; (c1 != t1.end()) && (c2 != t2.end()); ++c1, ++c2) - { - for (unsigned int v=0; v::vertices_per_cell; ++v) - { - if (c1->vertex(v) != c2->vertex(v)) - return false; - if (c1->vertex_index(v) != c2->vertex_index(v)) - return false; - } - - for (unsigned int f=0; f::faces_per_cell; ++f) - { - if (c1->face(f)->at_boundary() != c2->face(f)->at_boundary()) - return false; - - if (c1->face(f)->at_boundary()) - { - if (c1->face(f)->boundary_indicator() != - c2->face(f)->boundary_indicator()) - return false; - } - else - { - if (c1->neighbor(f)->level() != c2->neighbor(f)->level()) - return false; - if (c1->neighbor(f)->index() != c2->neighbor(f)->index()) - return false; - } - } - - if (c1->subdomain_id() != c2->subdomain_id()) - return false; - - if (c1->material_id() != c2->material_id()) - return false; - - if (c1->user_index() != c2->user_index()) - return false; - - if (c1->user_flag_set() != c2->user_flag_set()) - return false; - } - - // also check the order of raw iterators as they contain - // something about the history of the triangulation - typename Triangulation::cell_iterator - r1 = t1.begin_raw(), - r2 = t2.begin_raw(); - for (; (r1 != t1.end()) && (r2 != t2.end()); ++r1, ++r2) + template + bool operator == (const Triangulation &t1, + const Triangulation &t2) { - if (r1->level() != r2->level()) + // test a few attributes, though we can't + // test everything unfortunately... + if (t1.n_active_cells() != t2.n_active_cells()) return false; - if (r1->index() != r2->index()) + + if (t1.n_cells() != t2.n_cells()) return false; - } - return true; + if (t1.n_faces() != t2.n_faces()) + return false; + + typename Triangulation::cell_iterator + c1 = t1.begin(), + c2 = t2.begin(); + for (; (c1 != t1.end()) && (c2 != t2.end()); ++c1, ++c2) + { + for (unsigned int v=0; v::vertices_per_cell; ++v) + { + if (c1->vertex(v) != c2->vertex(v)) + return false; + if (c1->vertex_index(v) != c2->vertex_index(v)) + return false; + } + + for (unsigned int f=0; f::faces_per_cell; ++f) + { + if (c1->face(f)->at_boundary() != c2->face(f)->at_boundary()) + return false; + + if (c1->face(f)->at_boundary()) + { + if (c1->face(f)->boundary_indicator() != + c2->face(f)->boundary_indicator()) + return false; + } + else + { + if (c1->neighbor(f)->level() != c2->neighbor(f)->level()) + return false; + if (c1->neighbor(f)->index() != c2->neighbor(f)->index()) + return false; + } + } + + if (c1->subdomain_id() != c2->subdomain_id()) + return false; + + if (c1->material_id() != c2->material_id()) + return false; + + if (c1->user_index() != c2->user_index()) + return false; + + if (c1->user_flag_set() != c2->user_flag_set()) + return false; + } + + // also check the order of raw iterators as they contain + // something about the history of the triangulation + typename Triangulation::cell_iterator + r1 = t1.begin_raw(), + r2 = t2.begin_raw(); + for (; (r1 != t1.end()) && (r2 != t2.end()); ++r1, ++r2) + { + if (r1->level() != r2->level()) + return false; + if (r1->index() != r2->index()) + return false; + } + + return true; + } } + template void do_boundary (Triangulation &t1) { @@ -127,7 +131,7 @@ void test () tria_1.begin_active()->set_refine_flag (RefinementCase::cut_x); do_boundary (tria_1); - + verify (tria_1, tria_2); } @@ -145,6 +149,6 @@ int main () test<2,2> (); test<2,3> (); test<3,3> (); - + deallog << "OK" << std::endl; } diff --git a/tests/serialization/triangulation_02.cc b/tests/serialization/triangulation_02.cc index b4312be849..ddd53dff5e 100644 --- a/tests/serialization/triangulation_02.cc +++ b/tests/serialization/triangulation_02.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2010, 2011 by the deal.II authors +// Copyright (C) 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -22,83 +22,87 @@ #include "../../include/deal.II/grid/tria.h" -template -bool operator == (const Triangulation &t1, - const Triangulation &t2) +namespace dealii { - // test a few attributes, though we can't - // test everything unfortunately... - if (t1.n_active_cells() != t2.n_active_cells()) - return false; - - if (t1.n_cells() != t2.n_cells()) - return false; - - if (t1.n_faces() != t2.n_faces()) - return false; - - typename Triangulation::cell_iterator - c1 = t1.begin(), - c2 = t2.begin(); - for (; (c1 != t1.end()) && (c2 != t2.end()); ++c1, ++c2) - { - for (unsigned int v=0; v::vertices_per_cell; ++v) - { - if (c1->vertex(v) != c2->vertex(v)) - return false; - if (c1->vertex_index(v) != c2->vertex_index(v)) - return false; - } - - for (unsigned int f=0; f::faces_per_cell; ++f) - { - if (c1->face(f)->at_boundary() != c2->face(f)->at_boundary()) - return false; - - if (c1->face(f)->at_boundary()) - { - if (c1->face(f)->boundary_indicator() != - c2->face(f)->boundary_indicator()) - return false; - } - else - { - if (c1->neighbor(f)->level() != c2->neighbor(f)->level()) - return false; - if (c1->neighbor(f)->index() != c2->neighbor(f)->index()) - return false; - } - } - - if (c1->subdomain_id() != c2->subdomain_id()) - return false; - - if (c1->material_id() != c2->material_id()) - return false; - - if (c1->user_index() != c2->user_index()) - return false; - - if (c1->user_flag_set() != c2->user_flag_set()) - return false; - } - - // also check the order of raw iterators as they contain - // something about the history of the triangulation - typename Triangulation::cell_iterator - r1 = t1.begin_raw(), - r2 = t2.begin_raw(); - for (; (r1 != t1.end()) && (r2 != t2.end()); ++r1, ++r2) + template + bool operator == (const Triangulation &t1, + const Triangulation &t2) { - if (r1->level() != r2->level()) + // test a few attributes, though we can't + // test everything unfortunately... + if (t1.n_active_cells() != t2.n_active_cells()) return false; - if (r1->index() != r2->index()) + + if (t1.n_cells() != t2.n_cells()) return false; - } - return true; + if (t1.n_faces() != t2.n_faces()) + return false; + + typename Triangulation::cell_iterator + c1 = t1.begin(), + c2 = t2.begin(); + for (; (c1 != t1.end()) && (c2 != t2.end()); ++c1, ++c2) + { + for (unsigned int v=0; v::vertices_per_cell; ++v) + { + if (c1->vertex(v) != c2->vertex(v)) + return false; + if (c1->vertex_index(v) != c2->vertex_index(v)) + return false; + } + + for (unsigned int f=0; f::faces_per_cell; ++f) + { + if (c1->face(f)->at_boundary() != c2->face(f)->at_boundary()) + return false; + + if (c1->face(f)->at_boundary()) + { + if (c1->face(f)->boundary_indicator() != + c2->face(f)->boundary_indicator()) + return false; + } + else + { + if (c1->neighbor(f)->level() != c2->neighbor(f)->level()) + return false; + if (c1->neighbor(f)->index() != c2->neighbor(f)->index()) + return false; + } + } + + if (c1->subdomain_id() != c2->subdomain_id()) + return false; + + if (c1->material_id() != c2->material_id()) + return false; + + if (c1->user_index() != c2->user_index()) + return false; + + if (c1->user_flag_set() != c2->user_flag_set()) + return false; + } + + // also check the order of raw iterators as they contain + // something about the history of the triangulation + typename Triangulation::cell_iterator + r1 = t1.begin_raw(), + r2 = t2.begin_raw(); + for (; (r1 != t1.end()) && (r2 != t2.end()); ++r1, ++r2) + { + if (r1->level() != r2->level()) + return false; + if (r1->index() != r2->index()) + return false; + } + + return true; + } } + template void do_boundary (Triangulation &t1) { @@ -132,7 +136,7 @@ void test () // now add one cell again tria_1.begin_active()->set_refine_flag (); tria_1.execute_coarsening_and_refinement(); - + tria_1.begin_active()->set_subdomain_id (1); tria_1.begin_active()->set_material_id (2); tria_1.begin_active()->set_user_index (3); @@ -140,7 +144,7 @@ void test () tria_1.begin_active()->set_refine_flag (RefinementCase::cut_x); do_boundary (tria_1); - + verify (tria_1, tria_2); } @@ -158,6 +162,6 @@ int main () test<2,2> (); test<2,3> (); test<3,3> (); - + deallog << "OK" << std::endl; }