From: David Wells Date: Fri, 13 May 2016 18:26:17 +0000 (-0400) Subject: Fix compilation on clang. X-Git-Tag: v8.5.0-rc1~1039^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2600%2Fhead;p=dealii.git Fix compilation on clang. The previous commit 18ddfc4cf1 compiled under GCC but not clang. Credit goes to Wolfgang Bangerth for the suggested usage of a variadic function to raise errors when dim != spacedim. --- diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index 6aca950fea..051ff11e15 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -157,30 +157,18 @@ namespace GridTools * get the same result using cell-@>measure(), but this * function also works for cells that do not exist except that you make it * up by naming its vertices from the list. - * - * @note Since dim does not explicitly appear in the function - * signature, you must explicitly specify both dimensions when using this - * function. */ - template - double cell_measure (const std::vector > &all_vertices, + template + double cell_measure (const std::vector > &all_vertices, const unsigned int (&vertex_indices)[GeometryInfo::vertices_per_cell]); - /** - * Same as the last function, but for the codimension zero case. This extra - * function allows one to write - * - * @code - * cell_measure(vertices, indices); - * @endcode - * - * and have the template function argument (i.e. dim) inferred - * automatically. + * A version of the last function that can accept input for nonzero + * codimension cases. This function only exists to aid generic programming + * and calling it will just raise an exception. */ - template - double cell_measure (const std::vector > &all_vertices, - const unsigned int (&vertex_indices)[GeometryInfo::vertices_per_cell]); + template + double cell_measure (const T &, ...); /*@}*/ /** @@ -1655,17 +1643,13 @@ namespace GridTools namespace GridTools { - // This function just wraps the general case: see the note in its - // documentation above. - template - double cell_measure (const std::vector > &all_vertices, - const unsigned int (&vertex_indices)[GeometryInfo::vertices_per_cell]) + template + double cell_measure (const T &, ...) { - return cell_measure(all_vertices, vertex_indices); + Assert(false, ExcNotImplemented()); + return std::numeric_limits::quiet_NaN(); } - - template void transform (const Predicate &predicate, Triangulation &triangulation) diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 91dc5d834e..4141fb98f0 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -170,7 +170,7 @@ namespace GridTools template <> double - cell_measure<1, 1> + cell_measure<1> (const std::vector > &all_vertices, const unsigned int (&vertex_indices)[GeometryInfo<1>::vertices_per_cell]) { @@ -182,43 +182,7 @@ namespace GridTools template <> double - cell_measure<1, 2> - (const std::vector > &, - const unsigned int (&)[GeometryInfo<1>::vertices_per_cell]) - { - Assert(false, ExcNotImplemented()); - return std::numeric_limits::quiet_NaN(); - } - - - - template <> - double - cell_measure<1, 3> - (const std::vector > &, - const unsigned int (&)[GeometryInfo<1>::vertices_per_cell]) - { - Assert(false, ExcNotImplemented()); - return std::numeric_limits::quiet_NaN(); - } - - - - template <> - double - cell_measure<2, 3> - (const std::vector > &, - const unsigned int (&)[GeometryInfo<2>::vertices_per_cell]) - { - Assert(false, ExcNotImplemented()); - return std::numeric_limits::quiet_NaN(); - } - - - - template <> - double - cell_measure<3, 3> + cell_measure<3> (const std::vector > &all_vertices, const unsigned int (&vertex_indices)[GeometryInfo<3>::vertices_per_cell]) { @@ -342,7 +306,7 @@ namespace GridTools template <> double - cell_measure<2, 2> + cell_measure<2> (const std::vector > &all_vertices, const unsigned int (&vertex_indices) [GeometryInfo<2>::vertices_per_cell]) { diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 4d8351d568..a8de820411 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -1652,7 +1652,7 @@ namespace internal // throw an exception if no such cells should exist. if (!triangulation.check_for_distorted_cells) { - const double cell_measure = GridTools::cell_measure<1, spacedim> + const double cell_measure = GridTools::cell_measure<1> (triangulation.vertices, cells[cell_no].vertices); AssertThrow(cell_measure > 0, ExcGridHasInvalidCell(cell_no)); } @@ -1851,7 +1851,7 @@ namespace internal // See the note in the 1D function on this if statement. if (!triangulation.check_for_distorted_cells) { - const double cell_measure = GridTools::cell_measure<2, spacedim> + const double cell_measure = GridTools::cell_measure<2> (triangulation.vertices, cells[cell_no].vertices); AssertThrow(cell_measure > 0, ExcGridHasInvalidCell(cell_no)); } @@ -2234,7 +2234,7 @@ namespace internal // See the note in the 1D function on this if statement. if (!triangulation.check_for_distorted_cells) { - const double cell_measure = GridTools::cell_measure<3, spacedim> + const double cell_measure = GridTools::cell_measure<3> (triangulation.vertices, cells[cell_no].vertices); AssertThrow(cell_measure > 0, ExcGridHasInvalidCell(cell_no)); }