[Dune-devel] [PATCH] Use unqualified calls to allow ADL.

Christian Engwer christi at mathe-macht-spass.de
Wed Sep 2 10:48:53 CEST 2015


Dear Atgeirr,

now I understand the misunderstanding.

The idea was never to specialize the fvmeta functions. These functions
use internally standard math functions and these again can be
overloaded via ADL.

I adopted your example in the way we intended it, see the attached
file.

You specialized absreal, but you would have had to specialize abs.

Christian

On Wed, Sep 02, 2015 at 07:05:47AM +0000, Atgeirr Rasmussen wrote:
> Hello again, Dune!
> 
> Yesterday I promised:
> I will try to provide a minimal example tomorrow.
> 
> This is the minimal example. I compiled with the following command line (from my dune-common directory):
> 
> clang++ -std=c++11 -I. -o adlfail adlfail.cpp build-cmake/lib/libdunecommon.a
> 
> The version of clang is
> 
> Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
> 
> The source code to adlfail.cpp follows below. With current master, the include can be moved below Num
> (currently commented out) to compile successfully, with the patch applied it does not matter (and the
> absreal needs only to be defined in namespace Foobar).
> 
> I have also attached a new patch to this email, the only difference is that this is against the master branch.
> 
> Atgeirr
> 
> ========================================
> #include <dune/common/fmatrix.hh>
> 
> namespace Foobar
> {
>     struct Num
>     {
>         Num() {}
>         Num(double) {}
>         Num operator+(Num) const { return Num(); }
>         Num operator-(Num) const { return Num(); }
>         Num operator*(Num) const { return Num(); }
>         Num operator/(Num) const { return Num(); }
>         Num& operator+=(Num) { return *this; }
>         Num& operator-=(Num) { return *this; }
>         Num& operator*=(Num) { return *this; }
>         Num& operator/=(Num) { return *this; }
>         bool operator<(Num) const { return false; }
>         bool operator>(Num) const { return false; }
>     };
> 
>     Num operator/(double, Num) { return Num(); }
> 
>     double absreal(const Num&) { return 0.0; }
> }
> 
> namespace Dune
> {
>     namespace fvmeta
>     {
>         using Foobar::absreal;
>     }
> }
> 
> // #include <dune/common/fmatrix.hh>
> 
> int main()
> {
>     typedef Dune::FieldMatrix<Foobar::Num, 2, 2> Matrix;
>     typedef Dune::FieldVector<Foobar::Num, 2> Vector;
> 
>     Matrix M;
>     Vector x, y;
>     M.solve(x, y);
>     return 0;
> }
> =================================
> 


> _______________________________________________
> Dune-devel mailing list
> Dune-devel at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune-devel


-- 
Prof. Dr. Christian Engwer 
Institut für Numerische und Angewandte Mathematik
Fachbereich Mathematik und Informatik der Universität Münster
Einsteinstrasse 62
48149 Münster

E-Mail  christian.engwer at uni-muenster.de
Telefon +49 251 83-35067
FAX     +49 251 83-32729
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testfvectoradl.cc
Type: text/x-c++src
Size: 906 bytes
Desc: not available
URL: <https://lists.dune-project.org/pipermail/dune-devel/attachments/20150902/4daed797/attachment.cc>


More information about the Dune-devel mailing list