File: concepts.hh

package info (click to toggle)
dune-functions 2.10.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,544 kB
  • sloc: cpp: 14,241; python: 661; makefile: 3
file content (48 lines) | stat: -rw-r--r-- 1,256 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:

// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later

#ifndef DUNE_FUNCTIONS_BACKEND_CONCEPTS_HH
#define DUNE_FUNCTIONS_BACKEND_CONCEPTS_HH


#include <utility>

#include <dune/common/concept.hh>

namespace Dune {
namespace Functions {
namespace Concept {

using namespace Dune::Concept;


// Concept for a ConstVectorBackend
template<class GlobalBasis>
struct ConstVectorBackend
{
  template<class V>
  auto require(const V& v) -> decltype(
    v[std::declval<typename GlobalBasis::MultiIndex>()]
  );
};

// Concept for a VectorBackend
template<class GlobalBasis>
struct VectorBackend : Refines<ConstVectorBackend<GlobalBasis>>
{
  template<class V>
  auto require(const V& v) -> decltype(
    const_cast<V&>(v).resize(std::declval<const GlobalBasis&>()),
    const_cast<V&>(v)[std::declval<typename GlobalBasis::MultiIndex>()] = v[std::declval<typename GlobalBasis::MultiIndex>()]
  );
};

} // namespace Dune::Functions::Concept
} // namespace Dune::Functions
} // namespace Dune


#endif // DUNE_FUNCTIONS_BACKEND_CONCEPTS_HH