Skip to content
Snippets Groups Projects

Make FieldTraits less greedy

Open Carsten Gräser requested to merge feature/nongreedy-fieldtraits into master
  1. Jun 02, 2024
    • Simon Praetorius's avatar
    • Carsten Gräser's avatar
      Add FieldVector<K,1> constructor for expression templates · 397ec234
      Carsten Gräser authored and Simon Praetorius's avatar Simon Praetorius committed
      This overload is explicitly for type that do not implement
      `FieldTraits` but are still convertible to the stored
      scalar type. This is e.g. the case for `GMPField` expression templates.
      397ec234
    • Carsten Gräser's avatar
      [test][bugfix] Define FieldTraits for test implementation of a DenseVector · f36078c8
      Carsten Gräser authored and Simon Praetorius's avatar Simon Praetorius committed
      This is a bugfix. By not defining the traits class it implicitly used
      the default implementation which did not make any sense at all.
      
      BTW:
      It's a pitty that we have to define two traits classes for any
      `DenseVector` implementation `DenseMatVecTraits` and `FieldTraits`.
      But fixing this is another issue.
      f36078c8
    • Carsten Gräser's avatar
      Add a check if FieldTraits is empty · 46961e8a
      Carsten Gräser authored and Simon Praetorius's avatar Simon Praetorius committed
      This may be helful when constraining overloads, because
      any overload incorporation FieldTraits<T>::field_type
      in some enable_if check will be rules out due to SFINAE.
      
      This can be circumvented using FieldTraitsEmpty which
      would e.g. catch GMPField expression templatestemplates.
      46961e8a
    • Carsten Gräser's avatar
      Make FieldTraits less greedy · 0624b51b
      Carsten Gräser authored and Simon Praetorius's avatar Simon Praetorius committed
      The idea of the `FieldTraits` class is to provide
      the `field_type` and `real_type` of various types
      representing numbers, vectors, ... .
      So far there was a default implementation
      ```cpp
      template<class T>
      struct FieldTraits
      {
        typedef T field_type;
        typedef T real_type;
      };
      ```
      This does not make much sense, for types that do not
      represent numbers. The patch ensures that the default
      implementation does only provide the typedefs if
      `Dune::IsNumber<T>` is true and that it is empty
      otherwise.
      
      This also fixes a seemingly unrelated issue: If you
      defined `operator*(T,T)` and `dot(T,T)` for your own
      type (or concept) `T`, then `dot` is ambiguous,
      because there's a very greedy implementation in
      `dotproduct.hh`.
      0624b51b
Loading