[Dune-devel] [Dune-Commit] [Commit] dune-istl - 0f850d8: [BlockVector] modify constructor with capacity to catch at least some of the wrong invocations (see doxygen comment).
Markus Blatt
markus at dr-blatt.de
Thu Jul 4 21:40:17 CEST 2013
Hi,
is anybody really using this constructor on purpose? (I actually
cannot see, why I ever implemented it.)
No offence, but with this patch this is just ugly. I would prefer
throwing it out completely (and maybe add the cinstructor people would
exspect later)
Just my 2 cents,
Markus
On Thu, Jul 04, 2013 at 08:58:47PM +0200, Christian Engwer wrote:
> New commit, appeared at Thu Jul 4 20:58:47 2013 +0200
> as part of the following ref changes:
>
> branch refs/heads/master updated from 0f008a2 -> 0f850d8
>
> Browsable version: http://cgit.dune-project.org/repositories/dune-istl/commit/?id=0f850d8b756111431e9e1bec859c9ea4f95891dc
>
> ======================================================================
>
> commit 0f850d8b756111431e9e1bec859c9ea4f95891dc
> Author: Christian Engwer <christi at dune-project.org>
> Date: Thu Jul 4 20:58:51 2013 +0200
>
> [BlockVector]
> modify constructor with capacity to catch at least some of the
> wrong invocations (see doxygen comment).
>
> dune/istl/bvector.hh | 8 +++++++-
> dune/istl/test/bvectortest.cc | 3 +++
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
>
>
> diff --git a/dune/istl/bvector.hh b/dune/istl/bvector.hh
> index 32b7e82..6b2faee 100644
> --- a/dune/istl/bvector.hh
> +++ b/dune/istl/bvector.hh
> @@ -7,7 +7,9 @@
> #include <cmath>
> #include <complex>
> #include <memory>
> +#include <limits>
>
> +#include <dune/common/static_assert.hh>
> #include <dune/common/promotiontraits.hh>
> #include <dune/common/dotproduct.hh>
>
> @@ -313,8 +315,12 @@ namespace Dune {
> expecting to obtain a vector of 100 doubles initialized with zero.
> However, the code calls this constructor which tacitly does something else!
> */
> - BlockVector (size_type _n, size_type capacity)
> + template<typename S>
> + BlockVector (size_type _n, S _capacity)
> {
> + dune_static_assert( (std::numeric_limits<S>::is_integer),
> + "capacity must be an unsigned integral type (be aware, that this constructor does not set the default value!)" );
> + size_type capacity = _capacity;
> this->n = _n;
> if(this->n > capacity)
> capacity_ = _n;
> diff --git a/dune/istl/test/bvectortest.cc b/dune/istl/test/bvectortest.cc
> index 4e276da..a79d89b 100644
> --- a/dune/istl/test/bvectortest.cc
> +++ b/dune/istl/test/bvectortest.cc
> @@ -26,6 +26,9 @@ int testVector()
>
> // empty vector
> Vector v, w, v1(20), v2(20,100);
> +#ifdef FAIL
> + Vector v3(20,100.0);
> +#endif
> v.reserve(100);
> assert(100==v.capacity());
> assert(20==v1.capacity());
>
> _______________________________________________
> Dune-Commit mailing list
> Dune-Commit at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune-commit
>
--
Do you need more support with DUNE or HPC in general?
Dr. Markus Blatt - HPC-Simulation-Software & Services http://www.dr-blatt.de
Hans-Bunte-Str. 8-10, 69123 Heidelberg, Germany
Tel.: +49 (0) 160 97590858 Fax: +49 (0)322 1108991658
More information about the Dune-devel
mailing list