From 300eccc1364831a9199fe92cebd440ed57c6cea4 Mon Sep 17 00:00:00 2001 From: Felix Schindler <felix.schindler@wwu.de> Date: Sat, 15 Aug 2020 10:37:52 +0200 Subject: [PATCH] Revert "[py] move some enable_ifs to static asserts" This reverts commit 28bc70ca087ee1e5d806f50188ec3292c4e11b1e. --- dune/xt/common/matrix.hh | 34 +++++------ dune/xt/functions/base/reinterpret.hh | 17 +++--- dune/xt/functions/interfaces/function.hh | 3 +- dune/xt/functions/interfaces/grid-function.hh | 57 +++++++++---------- dune/xt/grid/gridprovider/cube.hh | 30 +++++----- dune/xt/grid/gridprovider/dgf.hh | 10 ++-- dune/xt/grid/gridprovider/gmsh.hh | 10 ++-- dune/xt/la/container/common/matrix/sparse.hh | 4 +- dune/xt/la/matrix-inverter.hh | 8 +-- dune/xt/la/solver.hh | 8 +-- .../xt/functions/function-as-grid-function.hh | 7 ++- python/dune/xt/functions/indicator.hh | 7 ++- .../xt/la/container/container-interface.hh | 3 +- .../dune/xt/la/container/matrix-interface.hh | 3 +- .../dune/xt/la/container/vector-interface.hh | 3 +- python/dune/xt/la/solver.hh | 3 +- 16 files changed, 104 insertions(+), 103 deletions(-) diff --git a/dune/xt/common/matrix.hh b/dune/xt/common/matrix.hh index e837f5bc2..c4dd5fb2d 100644 --- a/dune/xt/common/matrix.hh +++ b/dune/xt/common/matrix.hh @@ -292,33 +292,31 @@ struct MatrixAbstraction<Dune::FieldMatrix<K, N, M>> template <class MatrixType> -auto get_matrix_rows(const MatrixType& matrix) +typename std::enable_if<is_matrix<MatrixType>::value, size_t>::type get_matrix_rows(const MatrixType& matrix) { - static_assert(is_matrix<MatrixType>::value); return MatrixAbstraction<MatrixType>::rows(matrix); } template <class MatrixType> -auto get_matrix_cols(const MatrixType& matrix) +typename std::enable_if<is_matrix<MatrixType>::value, size_t>::type get_matrix_cols(const MatrixType& matrix) { - static_assert(is_matrix<MatrixType>::value); return MatrixAbstraction<MatrixType>::cols(matrix); } template <class MatrixType> -auto get_matrix_entry(const MatrixType& matrix, const size_t ii, const size_t jj) +typename std::enable_if<is_matrix<MatrixType>::value, typename MatrixAbstraction<MatrixType>::S>::type +get_matrix_entry(const MatrixType& matrix, const size_t ii, const size_t jj) { - static_assert(is_matrix<MatrixType>::value); return MatrixAbstraction<MatrixType>::get_entry(matrix, ii, jj); } template <class MatrixType, class S> -auto set_matrix_entry(MatrixType& matrix, const size_t ii, const size_t jj, const S& value) +typename std::enable_if<is_matrix<MatrixType>::value, void>::type +set_matrix_entry(MatrixType& matrix, const size_t ii, const size_t jj, const S& value) { - static_assert(is_matrix<MatrixType>::value); MatrixAbstraction<MatrixType>::set_entry(matrix, ii, jj, value); } @@ -328,12 +326,14 @@ template <class MatrixType, size_t COLS = MatrixAbstraction<MatrixType>::static_cols, class FieldType = typename MatrixAbstraction<MatrixType>::S, class SparsityPatternType = FullPattern> -auto create(const size_t rows, - const size_t cols, - const FieldType& val = 0, - const SparsityPatternType& pattern = SparsityPatternType()) +typename std::enable_if< + is_matrix<MatrixType>::value, + typename MatrixAbstraction<MatrixType>::template MatrixTypeTemplate<ROWS, COLS, FieldType>>::type +create(const size_t rows, + const size_t cols, + const FieldType& val = 0, + const SparsityPatternType& pattern = SparsityPatternType()) { - static_assert(is_matrix<MatrixType>::value); return MatrixAbstraction< typename MatrixAbstraction<MatrixType>::template MatrixTypeTemplate<ROWS, COLS, FieldType>>::create(rows, cols, @@ -343,18 +343,18 @@ auto create(const size_t rows, template <class TargetMatrixType, class SourceMatrixType> -auto zeros_like(const SourceMatrixType& source) +typename std::enable_if<is_matrix<TargetMatrixType>::value && is_matrix<SourceMatrixType>::value, + TargetMatrixType>::type +zeros_like(const SourceMatrixType& source) { - static_assert(is_matrix<TargetMatrixType>::value && is_matrix<SourceMatrixType>::value); return create<TargetMatrixType>( get_matrix_rows(source), get_matrix_cols(source), typename MatrixAbstraction<TargetMatrixType>::S(0)); } template <class MatrixType> -auto zeros_like(const MatrixType& source) +typename std::enable_if<is_matrix<MatrixType>::value, MatrixType>::type zeros_like(const MatrixType& source) { - static_assert(is_matrix<MatrixType>::value); return zeros_like<MatrixType, MatrixType>(source); } diff --git a/dune/xt/functions/base/reinterpret.hh b/dune/xt/functions/base/reinterpret.hh index 1058c8361..76c09d491 100644 --- a/dune/xt/functions/base/reinterpret.hh +++ b/dune/xt/functions/base/reinterpret.hh @@ -253,10 +253,11 @@ auto reinterpreted_source = reinterpret<TargetElement>(source, source_grid_view) * \sa ReinterpretLocalizableFunction */ template <class TargetElement, class SourceGridView, size_t r, size_t rC, class R> -auto reinterpret(const GridFunctionInterface<XT::Grid::extract_entity_t<SourceGridView>, r, rC, R>& source, - const SourceGridView& source_grid_view) +std::enable_if_t<XT::Grid::is_layer<SourceGridView>::value, + ReinterpretLocalizableFunction<SourceGridView, TargetElement, r, rC, R>> +reinterpret(const GridFunctionInterface<XT::Grid::extract_entity_t<SourceGridView>, r, rC, R>& source, + const SourceGridView& source_grid_view) { - static_assert(XT::Grid::is_layer<SourceGridView>::value); return ReinterpretLocalizableFunction<SourceGridView, TargetElement, r, rC, R>(source, source_grid_view); } @@ -268,12 +269,12 @@ auto reinterpret(const GridFunctionInterface<XT::Grid::extract_entity_t<SourceGr * \sa ReinterpretLocalizableFunction */ template <class SourceGridView, size_t r, size_t rC, class R, class TargetGridView> -auto reinterpret(const GridFunctionInterface<XT::Grid::extract_entity_t<SourceGridView>, r, rC, R>& source, - const SourceGridView& source_grid_view, - const TargetGridView& /*target_grid_view*/) +std::enable_if_t<XT::Grid::is_layer<SourceGridView>::value && XT::Grid::is_layer<TargetGridView>::value, + ReinterpretLocalizableFunction<SourceGridView, XT::Grid::extract_entity_t<TargetGridView>, r, rC, R>> +reinterpret(const GridFunctionInterface<XT::Grid::extract_entity_t<SourceGridView>, r, rC, R>& source, + const SourceGridView& source_grid_view, + const TargetGridView& /*target_grid_view*/) { - static_assert(XT::Grid::is_layer<SourceGridView>::value); - static_assert(XT::Grid::is_layer<TargetGridView>::value); return reinterpret<XT::Grid::extract_entity_t<TargetGridView>>(source, source_grid_view); } diff --git a/dune/xt/functions/interfaces/function.hh b/dune/xt/functions/interfaces/function.hh index 1f9701ee8..c95354353 100644 --- a/dune/xt/functions/interfaces/function.hh +++ b/dune/xt/functions/interfaces/function.hh @@ -199,7 +199,8 @@ public: } template <class OtherType> - auto operator*(const OtherType& other) const + typename std::enable_if<true, Functions::ProductFunction<ThisType, OtherType>>::type + operator*(const OtherType& other) const { return Functions::ProductFunction<ThisType, OtherType>(*this, other); } diff --git a/dune/xt/functions/interfaces/grid-function.hh b/dune/xt/functions/interfaces/grid-function.hh index 772dd1a52..265fde6ce 100644 --- a/dune/xt/functions/interfaces/grid-function.hh +++ b/dune/xt/functions/interfaces/grid-function.hh @@ -287,14 +287,14 @@ public: * visualization may thus be a refinement of the actual grid! */ template <class GridViewType> - void visualize(const GridViewType& grid_view, - const std::string path, - const bool subsampling = true, - const VTK::OutputType vtk_output_type = VTK::appendedraw, - const XT::Common::Parameter& param = {}, - const VisualizerInterface<r, rC, R>& visualizer = default_visualizer<r, rC, R>()) const + typename std::enable_if<Grid::is_view<GridViewType>::value, void>::type + visualize(const GridViewType& grid_view, + const std::string path, + const bool subsampling = true, + const VTK::OutputType vtk_output_type = VTK::appendedraw, + const XT::Common::Parameter& param = {}, + const VisualizerInterface<r, rC, R>& visualizer = default_visualizer<r, rC, R>()) const { - static_assert(Grid::is_view<GridViewType>::value); auto vtk_writer = create_vtkwriter(grid_view, subsampling); add_to_vtkwriter(*vtk_writer, param, visualizer); write_visualization(*vtk_writer, path, vtk_output_type); @@ -306,34 +306,33 @@ public: * \note Not yet implemented for vector-valued functions. */ template <class GridViewType> - void visualize_gradient(const GridViewType& grid_view, - const std::string path, - const bool subsampling = true, - const VTK::OutputType vtk_output_type = VTK::appendedraw, - const XT::Common::Parameter& param = {}, - const VisualizerInterface<d, 1, R>& visualizer = default_visualizer<d, 1, R>()) const + typename std::enable_if<Grid::is_view<GridViewType>::value, void>::type + visualize_gradient(const GridViewType& grid_view, + const std::string path, + const bool subsampling = true, + const VTK::OutputType vtk_output_type = VTK::appendedraw, + const XT::Common::Parameter& param = {}, + const VisualizerInterface<d, 1, R>& visualizer = default_visualizer<d, 1, R>()) const { - static_assert(Grid::is_view<GridViewType>::value); auto vtk_writer = create_vtkwriter(grid_view, subsampling); add_gradient_to_vtkwriter(*vtk_writer, param, visualizer); write_visualization(*vtk_writer, path, vtk_output_type); } // ... visualize_gradient(...) template <class GridViewType> - std::unique_ptr<VTKWriter<GridViewType>> create_vtkwriter(const GridViewType& grid_view, - const bool subsampling = true) const + typename std::enable_if<Grid::is_view<GridViewType>::value, std::unique_ptr<VTKWriter<GridViewType>>>::type + create_vtkwriter(const GridViewType& grid_view, const bool subsampling = true) const { - static_assert(Grid::is_view<GridViewType>::value); return subsampling ? std::make_unique<SubsamplingVTKWriter<GridViewType>>(grid_view, /*subsampling_level=*/2) : std::make_unique<VTKWriter<GridViewType>>(grid_view, VTK::nonconforming); } template <class GridViewType> - void add_to_vtkwriter(VTKWriter<GridViewType>& vtk_writer, - const XT::Common::Parameter& param = {}, - const VisualizerInterface<r, rC, R>& visualizer = default_visualizer<r, rC, R>()) const + typename std::enable_if<Grid::is_view<GridViewType>::value, void>::type + add_to_vtkwriter(VTKWriter<GridViewType>& vtk_writer, + const XT::Common::Parameter& param = {}, + const VisualizerInterface<r, rC, R>& visualizer = default_visualizer<r, rC, R>()) const { - static_assert(Grid::is_view<GridViewType>::value); const auto adapter = std::make_shared<VisualizationAdapter<GridViewType, range_dim, range_dim_cols, RangeFieldType>>( *this, visualizer, "", param); @@ -341,11 +340,11 @@ public: } template <class GridViewType> - void add_gradient_to_vtkwriter(VTKWriter<GridViewType>& vtk_writer, - const XT::Common::Parameter& param = {}, - const VisualizerInterface<d, 1, R>& visualizer = default_visualizer<d, 1, R>()) const + typename std::enable_if<Grid::is_view<GridViewType>::value, void>::type + add_gradient_to_vtkwriter(VTKWriter<GridViewType>& vtk_writer, + const XT::Common::Parameter& param = {}, + const VisualizerInterface<d, 1, R>& visualizer = default_visualizer<d, 1, R>()) const { - static_assert(Grid::is_view<GridViewType>::value); const auto adapter = std::make_shared<GradientVisualizationAdapter<GridViewType, range_dim, range_dim_cols, RangeFieldType>>( *this, visualizer, "", param); @@ -353,11 +352,11 @@ public: } template <class GridViewType> - auto write_visualization(VTKWriter<GridViewType>& vtk_writer, - const std::string path, - const VTK::OutputType vtk_output_type = VTK::appendedraw) const + typename std::enable_if<Grid::is_view<GridViewType>::value, void>::type + write_visualization(VTKWriter<GridViewType>& vtk_writer, + const std::string path, + const VTK::OutputType vtk_output_type = VTK::appendedraw) const { - static_assert(Grid::is_view<GridViewType>::value); if (path.empty()) DUNE_THROW(Exceptions::wrong_input_given, "path must not be empty!"); const auto directory = Common::directory_only(path); diff --git a/dune/xt/grid/gridprovider/cube.hh b/dune/xt/grid/gridprovider/cube.hh index 773944f7d..64b1a1977 100644 --- a/dune/xt/grid/gridprovider/cube.hh +++ b/dune/xt/grid/gridprovider/cube.hh @@ -217,7 +217,7 @@ public: template <class GridType> -auto make_cube_grid( +typename std::enable_if<is_grid<GridType>::value, GridProvider<GridType>>::type make_cube_grid( const FieldVector<typename GridType::ctype, GridType::dimension>& lower_left, const FieldVector<typename GridType::ctype, GridType::dimension>& upper_right, const std::array<unsigned int, GridType::dimension> num_elements = @@ -228,35 +228,33 @@ auto make_cube_grid( cube_gridprovider_default_config().template get<std::array<unsigned int, GridType::dimension>>("overlap_size"), MPIHelper::MPICommunicator mpi_comm = MPIHelper::getCommunicator()) { - static_assert(is_grid<GridType>::value); return CubeGridProviderFactory<GridType>::create( lower_left, upper_right, num_elements, num_refinements, overlap_size, mpi_comm); } template <class GridType> -auto make_cube_grid( - const typename GridType::ctype& lower_left, - const typename GridType::ctype& upper_right, - const unsigned int num_elements = - cube_gridprovider_default_config().template get<std::vector<unsigned int>>("num_elements").at(0), - const unsigned int num_refinements = - cube_gridprovider_default_config().template get<unsigned int>("num_refinements"), - const unsigned int overlap_size = - cube_gridprovider_default_config().template get<std::vector<unsigned int>>("overlap_size").at(0), - MPIHelper::MPICommunicator mpi_comm = MPIHelper::getCommunicator()) +typename std::enable_if<is_grid<GridType>::value, GridProvider<GridType>>::type +make_cube_grid(const typename GridType::ctype& lower_left, + const typename GridType::ctype& upper_right, + const unsigned int num_elements = + cube_gridprovider_default_config().template get<std::vector<unsigned int>>("num_elements").at(0), + const unsigned int num_refinements = + cube_gridprovider_default_config().template get<unsigned int>("num_refinements"), + const unsigned int overlap_size = + cube_gridprovider_default_config().template get<std::vector<unsigned int>>("overlap_size").at(0), + MPIHelper::MPICommunicator mpi_comm = MPIHelper::getCommunicator()) { - static_assert(is_grid<GridType>::value); return CubeGridProviderFactory<GridType>::create( lower_left, upper_right, num_elements, num_refinements, overlap_size, mpi_comm); } template <class GridType> -auto make_cube_grid(const Common::Configuration& cfg = cube_gridprovider_default_config(), - MPIHelper::MPICommunicator mpi_comm = MPIHelper::getCommunicator()) +typename std::enable_if<is_grid<GridType>::value, GridProvider<GridType>>::type +make_cube_grid(const Common::Configuration& cfg = cube_gridprovider_default_config(), + MPIHelper::MPICommunicator mpi_comm = MPIHelper::getCommunicator()) { - static_assert(is_grid<GridType>::value); return CubeGridProviderFactory<GridType>::create(cfg, mpi_comm); } diff --git a/dune/xt/grid/gridprovider/dgf.hh b/dune/xt/grid/gridprovider/dgf.hh index bf33cd46e..f557135c2 100644 --- a/dune/xt/grid/gridprovider/dgf.hh +++ b/dune/xt/grid/gridprovider/dgf.hh @@ -81,18 +81,18 @@ public: template <class GridType> -auto make_dgf_grid(const std::string& filename, MPIHelper::MPICommunicator mpi_comm = MPIHelper::getCommunicator()) +typename std::enable_if<is_grid<GridType>::value, GridProvider<GridType>>::type +make_dgf_grid(const std::string& filename, MPIHelper::MPICommunicator mpi_comm = MPIHelper::getCommunicator()) { - static_assert(is_grid<GridType>::value); return DgfGridProviderFactory<GridType>(filename, mpi_comm); } template <class GridType> -auto make_dgf_grid(const Common::Configuration& cfg = DgfGridProviderFactory<GridType>::default_config(), - MPIHelper::MPICommunicator mpi_comm = MPIHelper::getCommunicator()) +typename std::enable_if<is_grid<GridType>::value, GridProvider<GridType>>::type +make_dgf_grid(const Common::Configuration& cfg = DgfGridProviderFactory<GridType>::default_config(), + MPIHelper::MPICommunicator mpi_comm = MPIHelper::getCommunicator()) { - static_assert(is_grid<GridType>::value); return DgfGridProviderFactory<GridType>::create(cfg, mpi_comm); } diff --git a/dune/xt/grid/gridprovider/gmsh.hh b/dune/xt/grid/gridprovider/gmsh.hh index 9ab191860..a9c2dd34a 100644 --- a/dune/xt/grid/gridprovider/gmsh.hh +++ b/dune/xt/grid/gridprovider/gmsh.hh @@ -114,18 +114,18 @@ public: template <class GridType> -auto make_gmsh_grid(const std::string& filename, MPIHelper::MPICommunicator mpi_comm = MPIHelper::getCommunicator()) +typename std::enable_if<is_grid<GridType>::value, GridProvider<GridType>>::type +make_gmsh_grid(const std::string& filename, MPIHelper::MPICommunicator mpi_comm = MPIHelper::getCommunicator()) { - static_assert(is_grid<GridType>::value); return GmshGridProviderFactory<GridType>::create(filename, mpi_comm); } template <class GridType> -auto make_gmsh_grid(const Common::Configuration& cfg = GmshGridProviderFactory<GridType>::default_config(), - MPIHelper::MPICommunicator mpi_comm = MPIHelper::getCommunicator()) +typename std::enable_if<is_grid<GridType>::value, GridProvider<GridType>>::type +make_gmsh_grid(const Common::Configuration& cfg = GmshGridProviderFactory<GridType>::default_config(), + MPIHelper::MPICommunicator mpi_comm = MPIHelper::getCommunicator()) { - static_assert(is_grid<GridType>::value); return GmshGridProviderFactory<GridType>::create(cfg, mpi_comm); } diff --git a/dune/xt/la/container/common/matrix/sparse.hh b/dune/xt/la/container/common/matrix/sparse.hh index 14fc0116a..8867a7077 100644 --- a/dune/xt/la/container/common/matrix/sparse.hh +++ b/dune/xt/la/container/common/matrix/sparse.hh @@ -232,9 +232,9 @@ public: } template <class OtherMatrixImp> - ThisType& assign(const OtherMatrixImp& other, const SparsityPatternDefault& pattern) + typename std::enable_if_t<XT::Common::MatrixAbstraction<OtherMatrixImp>::is_matrix, ThisType>& + assign(const OtherMatrixImp& other, const SparsityPatternDefault& pattern) { - static_assert(XT::Common::MatrixAbstraction<OtherMatrixImp>::is_matrix); clear(); using MatAbstrType = XT::Common::MatrixAbstraction<OtherMatrixImp>; num_rows_ = MatAbstrType::rows(other); diff --git a/dune/xt/la/matrix-inverter.hh b/dune/xt/la/matrix-inverter.hh index cf25d8519..c1a7eea87 100644 --- a/dune/xt/la/matrix-inverter.hh +++ b/dune/xt/la/matrix-inverter.hh @@ -111,17 +111,17 @@ MatrixInverter<M> make_matrix_inverter(const M& matrix, const Common::Configurat template <class M> -auto invert_matrix(const M& matrix, const std::string& inversion_type = "") +typename std::enable_if<is_matrix<M>::value || Common::is_matrix<M>::value, M>::type +invert_matrix(const M& matrix, const std::string& inversion_type = "") { - static_assert(is_matrix<M>::value || Common::is_matrix<M>::value); return MatrixInverter<M>(matrix, inversion_type).inverse(); } template <class M> -auto invert_matrix(const M& matrix, const Common::Configuration& inversion_options) +typename std::enable_if<is_matrix<M>::value || Common::is_matrix<M>::value, M>::type +invert_matrix(const M& matrix, const Common::Configuration& inversion_options) { - static_assert(is_matrix<M>::value || Common::is_matrix<M>::value); return MatrixInverter<M>(matrix, inversion_options).inverse(); } diff --git a/dune/xt/la/solver.hh b/dune/xt/la/solver.hh index 37714483b..dd96d990b 100644 --- a/dune/xt/la/solver.hh +++ b/dune/xt/la/solver.hh @@ -141,17 +141,17 @@ public: template <class M> -auto make_solver(const M& matrix) +typename std::enable_if<is_matrix<M>::value || XT::Common::is_matrix<M>::value, Solver<M>>::type +make_solver(const M& matrix) { - static_assert(is_matrix<M>::value || XT::Common::is_matrix<M>::value); return Solver<M>(matrix); } template <class M, class V, class... Args> -void solve(const M& A, const V& b, V& x, Args&&... args) +typename std::enable_if<is_matrix<M>::value && is_vector<V>::value, void>::type +solve(const M& A, const V& b, V& x, Args&&... args) { - static_assert(is_matrix<M>::value && is_vector<V>::value); make_solver(A).apply(b, x, std::forward<Args>(args)...); } diff --git a/python/dune/xt/functions/function-as-grid-function.hh b/python/dune/xt/functions/function-as-grid-function.hh index 62c12a304..452234e4c 100644 --- a/python/dune/xt/functions/function-as-grid-function.hh +++ b/python/dune/xt/functions/function-as-grid-function.hh @@ -27,9 +27,12 @@ namespace bindings { template <class G, size_t d, size_t r, size_t rC> -auto bind_FunctionAsGridFunctionWrapper(pybind11::module& m, const std::string& grid_id) +typename std::enable_if< + Grid::is_grid<G>::value, + pybind11::class_<FunctionAsGridFunctionWrapper<typename G::template Codim<0>::Entity, r, rC, double>, + GridFunctionInterface<typename G::template Codim<0>::Entity, r, rC, double>>>::type +bind_FunctionAsGridFunctionWrapper(pybind11::module& m, const std::string& grid_id) { - static_assert(Grid::is_grid<G>::value); namespace py = pybind11; using namespace pybind11::literals; diff --git a/python/dune/xt/functions/indicator.hh b/python/dune/xt/functions/indicator.hh index e48553964..797c962c7 100644 --- a/python/dune/xt/functions/indicator.hh +++ b/python/dune/xt/functions/indicator.hh @@ -30,9 +30,12 @@ namespace Functions { template <class G, size_t d, size_t r, size_t rC> -auto bind_IndicatorGridFunction(pybind11::module& m, const std::string& grid_id) +typename std::enable_if< + Grid::is_grid<G>::value, + pybind11::class_<IndicatorGridFunction<typename G::template Codim<0>::Entity, r, rC, double>, + GridFunctionInterface<typename G::template Codim<0>::Entity, r, rC, double>>>::type +bind_IndicatorGridFunction(pybind11::module& m, const std::string& grid_id) { - static_assert(Grid::is_grid<G>::value); namespace py = pybind11; using namespace pybind11::literals; diff --git a/python/dune/xt/la/container/container-interface.hh b/python/dune/xt/la/container/container-interface.hh index 939508999..7f94a87eb 100644 --- a/python/dune/xt/la/container/container-interface.hh +++ b/python/dune/xt/la/container/container-interface.hh @@ -45,9 +45,8 @@ pybind11::enum_<Backends> bind_Backends(pybind11::module& m) template <class C> -void addbind_ContainerInterface(pybind11::class_<C>& c) +typename std::enable_if<is_container<C>::value, void>::type addbind_ContainerInterface(pybind11::class_<C>& c) { - static_assert(is_container<C>::value); namespace py = pybind11; using namespace pybind11::literals; diff --git a/python/dune/xt/la/container/matrix-interface.hh b/python/dune/xt/la/container/matrix-interface.hh index eb167b05e..72bf04e44 100644 --- a/python/dune/xt/la/container/matrix-interface.hh +++ b/python/dune/xt/la/container/matrix-interface.hh @@ -85,9 +85,8 @@ void print_row_sparsely(const M& self, const size_t row, std::stringstream& ss) template <class C, bool sparse> -auto bind_Matrix(pybind11::module& m) +typename std::enable_if<is_matrix<C>::value, pybind11::class_<C>>::type bind_Matrix(pybind11::module& m) { - static_assert(is_matrix<C>::value); namespace py = pybind11; using namespace pybind11::literals; diff --git a/python/dune/xt/la/container/vector-interface.hh b/python/dune/xt/la/container/vector-interface.hh index 8a7d7141f..e1b577a3a 100644 --- a/python/dune/xt/la/container/vector-interface.hh +++ b/python/dune/xt/la/container/vector-interface.hh @@ -34,9 +34,8 @@ namespace LA { template <class C> -auto bind_Vector(pybind11::module& m) +typename std::enable_if<is_vector<C>::value, pybind11::class_<C>>::type bind_Vector(pybind11::module& m) { - static_assert(is_vector<C>::value); namespace py = pybind11; using namespace pybind11::literals; diff --git a/python/dune/xt/la/solver.hh b/python/dune/xt/la/solver.hh index 1cdbf7a34..dd46e1a4d 100644 --- a/python/dune/xt/la/solver.hh +++ b/python/dune/xt/la/solver.hh @@ -28,9 +28,8 @@ namespace LA { template <class M, class V = typename Container<typename M::ScalarType, M::vector_type>::VectorType> -auto bind_Solver(pybind11::module& m) +typename std::enable_if<is_matrix<M>::value, pybind11::class_<Solver<M>>>::type bind_Solver(pybind11::module& m) { - static_assert(is_matrix<M>::value); typedef Solver<M> C; namespace py = pybind11; -- GitLab