Commit ca9389e1 authored by Christoph Grüninger's avatar Christoph Grüninger
Browse files

Merge branch 'feature/maybe_unused-replace-DUNE_UNUSED' into 'master'

Feature/maybe unused replace dune unused

See merge request !946
parents 0cab3f48 e2a1d550
Pipeline #35388 passed with stage
in 7 minutes and 53 seconds
......@@ -86,6 +86,12 @@
`[[deprecated]]` but be aware that it is no drop-in replacement,
as it must be sometimes placed at different position in the code.
- The macros `DUNE_UNUSED` is deprecated and will be removed after
Dune 2.8. Use C++17's attribute `[[maybe_unused]]` instead, but be
aware that it is no drop-in replacement, as it must be sometimes
placed at different position in the code.
The use of `DUNE_UNUSED_PARAMETER` is discouraged.
# Release 2.7
- Added fallback implementation to C++20 feature: `std::identity`.
......
......@@ -39,10 +39,8 @@ namespace Dune
static constexpr int alignment = fixAlignment(sizeof(void*));
//! allocate n objects of type T
pointer allocate(size_type n, const void* hint = 0)
pointer allocate(size_type n, [[maybe_unused]] const void* hint = 0)
{
DUNE_UNUSED_PARAMETER(hint);
if (n > this->max_size())
throw std::bad_alloc();
......
......@@ -9,7 +9,6 @@
#define HAVE_SYS_MMAN_H 1
#define HAVE_MPROTECT 1
#include <dune/common/unused.hh>
#include <exception>
#include <typeinfo>
#include <vector>
......@@ -65,7 +64,9 @@ namespace Dune
AllocationList allocation_list;
private:
void memprotect(void* from, difference_type len, int prot)
void memprotect([[maybe_unused]] void* from,
[[maybe_unused]] difference_type len,
[[maybe_unused]] int prot)
{
#if HAVE_SYS_MMAN_H && HAVE_MPROTECT
int result = mprotect(from, len, prot);
......@@ -86,9 +87,6 @@ namespace Dune
abort();
}
#else
DUNE_UNUSED_PARAMETER(from);
DUNE_UNUSED_PARAMETER(len);
DUNE_UNUSED_PARAMETER(prot);
std::cerr << "WARNING: memory protection not available" << std::endl;
#endif
}
......@@ -263,9 +261,8 @@ namespace Dune
//! allocate n objects of type T
pointer allocate(size_type n,
DebugAllocator<void>::const_pointer hint = 0)
[[maybe_unused]] DebugAllocator<void>::const_pointer hint = 0)
{
DUNE_UNUSED_PARAMETER(hint);
return DebugMemory::alloc_man.allocate<T>(n);
}
......
......@@ -19,7 +19,6 @@
#include <dune/common/precision.hh>
#include <dune/common/simd/simd.hh>
#include <dune/common/typetraits.hh>
#include <dune/common/unused.hh>
#include <dune/common/scalarvectorview.hh>
namespace Dune
......@@ -55,9 +54,8 @@ namespace Dune
struct [[deprecated("VectorSize is deprecated; please call the 'size()' method directly instead")]] VectorSize< const FieldVector<K,N> >
{
typedef FieldVector<K,N> V;
static typename V::size_type size(const V & v)
static typename V::size_type size([[maybe_unused]] const V & v)
{
DUNE_UNUSED_PARAMETER(v);
return N;
}
};
......@@ -750,10 +748,8 @@ namespace Dune
//===== query
//! return true when (i,j) is in pattern
bool exists (size_type i, size_type j) const
bool exists ([[maybe_unused]] size_type i, [[maybe_unused]] size_type j) const
{
DUNE_UNUSED_PARAMETER(i);
DUNE_UNUSED_PARAMETER(j);
DUNE_ASSERT_BOUNDS(i >= 0 && i < rows());
DUNE_ASSERT_BOUNDS(j >= 0 && j < cols());
return true;
......
......@@ -23,7 +23,6 @@
#include <dune/common/fvector.hh>
#include <dune/common/genericiterator.hh>
#include <dune/common/typetraits.hh>
#include <dune/common/unused.hh>
namespace Dune {
......@@ -718,9 +717,8 @@ namespace Dune {
//===== access to components
//! same for read only access
const K& operator[] (size_type i) const
const K& operator[] ([[maybe_unused]] size_type i) const
{
DUNE_UNUSED_PARAMETER(i);
DUNE_ASSERT_BOUNDS(i == row_);
return *p_;
}
......@@ -797,15 +795,13 @@ namespace Dune {
protected:
size_type realIndex(int i) const
size_type realIndex([[maybe_unused]] int i) const
{
DUNE_UNUSED_PARAMETER(i);
return rowIndex();
}
K* pointer(size_type i) const
K* pointer([[maybe_unused]] size_type i) const
{
DUNE_UNUSED_PARAMETER(i);
return const_cast<K*>(p_);
}
......@@ -859,9 +855,8 @@ namespace Dune {
//===== access to components
//! random access
K& operator[] (size_type i)
K& operator[] ([[maybe_unused]] size_type i)
{
DUNE_UNUSED_PARAMETER(i);
DUNE_ASSERT_BOUNDS(i == row_);
return *p_;
}
......
......@@ -4,7 +4,6 @@
#define DUNE_ENUMSET_HH
#include <iostream>
#include <dune/common/unused.hh>
namespace Dune
{
......@@ -113,16 +112,14 @@ namespace Dune
};
template<typename TA>
inline bool EmptySet<TA>::contains(const Type& attribute)
inline bool EmptySet<TA>::contains([[maybe_unused]] const Type& attribute)
{
DUNE_UNUSED_PARAMETER(attribute);
return false;
}
template<typename TA>
inline bool AllSet<TA>::contains(const Type& attribute)
inline bool AllSet<TA>::contains([[maybe_unused]] const Type& attribute)
{
DUNE_UNUSED_PARAMETER(attribute);
return true;
}
......@@ -158,10 +155,9 @@ namespace Dune
}
template<class TI1, class TI2>
inline Combine<TI1,TI2,typename TI1::Type> combine(const TI1& set1, const TI2& set2)
inline Combine<TI1,TI2,typename TI1::Type> combine([[maybe_unused]] const TI1& set1,
[[maybe_unused]] const TI2& set2)
{
DUNE_UNUSED_PARAMETER(set1);
DUNE_UNUSED_PARAMETER(set2);
return Combine<TI1,TI2,typename TI1::Type>();
}
......
......@@ -463,16 +463,14 @@ namespace Dune
static constexpr size_type mat_rows() { return 1; }
static constexpr size_type mat_cols() { return 1; }
row_reference mat_access ( size_type i )
row_reference mat_access ([[maybe_unused]] size_type i)
{
DUNE_UNUSED_PARAMETER(i);
DUNE_ASSERT_BOUNDS(i == 0);
return _data;
}
const_row_reference mat_access ( size_type i ) const
const_row_reference mat_access ([[maybe_unused]] size_type i) const
{
DUNE_UNUSED_PARAMETER(i);
DUNE_ASSERT_BOUNDS(i == 0);
return _data;
}
......
......@@ -12,7 +12,6 @@
#include <cassert>
#include <dune/common/exceptions.hh>
#include <dune/common/unused.hh>
#if HAVE_LAPACK
......
......@@ -18,7 +18,6 @@
#include "ftraits.hh"
#include "densevector.hh"
#include "unused.hh"
#include "boundschecking.hh"
#include <dune/common/math.hh>
......@@ -166,9 +165,9 @@ namespace Dune {
* \param[in] dummy A void* dummy argument needed by SFINAE.
*/
template<class C>
FieldVector (const DenseVector<C> & x, typename std::enable_if<IsFieldVectorSizeCorrect<C,SIZE>::value>::type* dummy=0 )
FieldVector (const DenseVector<C> & x,
[[maybe_unused]] typename std::enable_if<IsFieldVectorSizeCorrect<C,SIZE>::value>::type* dummy=0)
{
DUNE_UNUSED_PARAMETER(dummy);
// do a run-time size check, for the case that x is not a FieldVector
assert(x.size() == SIZE); // Actually this is not needed any more!
std::copy_n(x.begin(), std::min(static_cast<std::size_t>(SIZE),x.size()), _data.begin());
......@@ -375,15 +374,13 @@ namespace Dune {
//===== forward methods to container
static constexpr size_type size () { return 1; }
K & operator[](size_type i)
K & operator[]([[maybe_unused]] size_type i)
{
DUNE_UNUSED_PARAMETER(i);
DUNE_ASSERT_BOUNDS(i == 0);
return _data;
}
const K & operator[](size_type i) const
const K & operator[]([[maybe_unused]] size_type i) const
{
DUNE_UNUSED_PARAMETER(i);
DUNE_ASSERT_BOUNDS(i == 0);
return _data;
}
......
......@@ -11,7 +11,6 @@
#include <dune/common/fvector.hh>
#include <dune/common/indices.hh>
#include <dune/common/assertandreturn.hh>
#include <dune/common/unused.hh>
#include <dune/common/rangeutilities.hh>
......
......@@ -9,7 +9,6 @@
#include <memory>
#include <dune/common/exceptions.hh>
#include <dune/common/unused.hh>
/** @file
@author Christian Engwer
......@@ -97,9 +96,8 @@ namespace Dune {
* Returns a read-only (constant) reference to the data of the
* least recently used entry.
*/
const_reference back (int i) const
const_reference back ([[maybe_unused]] int i) const
{
DUNE_UNUSED_PARAMETER(i);
return _data.back().second;
}
......
......@@ -7,7 +7,6 @@
#include <cstdlib>
#include <new>
#include <utility>
#include <dune/common/unused.hh>
/**
* @file
......@@ -52,9 +51,8 @@ namespace Dune
//! allocate n objects of type T
pointer allocate(size_type n,
const void* hint = 0)
[[maybe_unused]] const void* hint = 0)
{
DUNE_UNUSED_PARAMETER(hint);
if (n > this->max_size())
throw std::bad_alloc();
......@@ -65,9 +63,8 @@ namespace Dune
}
//! deallocate n objects of type T at address p
void deallocate(pointer p, size_type n)
void deallocate(pointer p, [[maybe_unused]] size_type n)
{
DUNE_UNUSED_PARAMETER(n);
std::free(p);
}
......
......@@ -16,7 +16,6 @@
#include <dune/common/binaryfunctions.hh>
#include <dune/common/exceptions.hh>
#include <dune/common/unused.hh>
#include <dune/common/parallel/future.hh>
/*! \defgroup ParallelCommunication Parallel Communication
......@@ -131,10 +130,10 @@ namespace Dune
@returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise
*/
template<class T>
int send(const T& data, int dest_rank, int tag){
DUNE_UNUSED_PARAMETER(data);
DUNE_UNUSED_PARAMETER(dest_rank);
DUNE_UNUSED_PARAMETER(tag);
int send([[maybe_unused]] const T& data,
[[maybe_unused]] int dest_rank,
[[maybe_unused]] int tag)
{
DUNE_THROW(ParallelError, "This method is not supported in sequential programs");
}
......@@ -142,10 +141,10 @@ namespace Dune
@returns Future<T> containing the send buffer, completes when data is send
*/
template<class T>
PseudoFuture<T> isend(const T&& data, int dest_rank, int tag){
DUNE_UNUSED_PARAMETER(data);
DUNE_UNUSED_PARAMETER(dest_rank);
DUNE_UNUSED_PARAMETER(tag);
PseudoFuture<T> isend([[maybe_unused]] const T&& data,
[[maybe_unused]] int dest_rank,
[[maybe_unused]] int tag)
{
DUNE_THROW(ParallelError, "This method is not supported in sequential programs");
}
......@@ -153,11 +152,11 @@ namespace Dune
@returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise
*/
template<class T>
T recv(T&& data, int source_rank, int tag, void* status = 0){
DUNE_UNUSED_PARAMETER(data);
DUNE_UNUSED_PARAMETER(source_rank);
DUNE_UNUSED_PARAMETER(tag);
DUNE_UNUSED_PARAMETER(status);
T recv([[maybe_unused]] T&& data,
[[maybe_unused]] int source_rank,
[[maybe_unused]] int tag,
[[maybe_unused]] void* status = 0)
{
DUNE_THROW(ParallelError, "This method is not supported in sequential programs");
}
......@@ -165,20 +164,19 @@ namespace Dune
@returns Future<T> containing the received data when complete
*/
template<class T>
PseudoFuture<T> irecv(T&& data, int source_rank, int tag){
DUNE_UNUSED_PARAMETER(data);
DUNE_UNUSED_PARAMETER(source_rank);
DUNE_UNUSED_PARAMETER(tag);
PseudoFuture<T> irecv([[maybe_unused]] T&& data,
[[maybe_unused]] int source_rank,
[[maybe_unused]] int tag)
{
DUNE_THROW(ParallelError, "This method is not supported in sequential programs");
}
template<class T>
T rrecv(T&& data, int source_rank, int tag, void* status = 0) const
T rrecv([[maybe_unused]] T&& data,
[[maybe_unused]] int source_rank,
[[maybe_unused]] int tag,
[[maybe_unused]] void* status = 0) const
{
DUNE_UNUSED_PARAMETER(data);
DUNE_UNUSED_PARAMETER(source_rank);
DUNE_UNUSED_PARAMETER(tag);
DUNE_UNUSED_PARAMETER(status);
DUNE_THROW(ParallelError, "This method is not supported in sequential programs");
}
/** @brief Compute the sum of the argument over all processes and
......@@ -196,10 +194,8 @@ namespace Dune
@returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise
*/
template<typename T>
int sum (T* inout, int len) const
int sum ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const
{
DUNE_UNUSED_PARAMETER(inout);
DUNE_UNUSED_PARAMETER(len);
return 0;
}
......@@ -218,10 +214,8 @@ namespace Dune
@returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise
*/
template<typename T>
int prod (T* inout, int len) const
int prod ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const
{
DUNE_UNUSED_PARAMETER(inout);
DUNE_UNUSED_PARAMETER(len);
return 0;
}
......@@ -240,10 +234,8 @@ namespace Dune
@returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise
*/
template<typename T>
int min (T* inout, int len) const
int min ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const
{
DUNE_UNUSED_PARAMETER(inout);
DUNE_UNUSED_PARAMETER(len);
return 0;
}
......@@ -262,10 +254,8 @@ namespace Dune
@returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise
*/
template<typename T>
int max (T* inout, int len) const
int max ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const
{
DUNE_UNUSED_PARAMETER(inout);
DUNE_UNUSED_PARAMETER(len);
return 0;
}
......@@ -289,11 +279,10 @@ namespace Dune
@returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise
*/
template<typename T>
int broadcast (T* inout, int len, int root) const
int broadcast ([[maybe_unused]] T* inout,
[[maybe_unused]] int len,
[[maybe_unused]] int root) const
{
DUNE_UNUSED_PARAMETER(inout);
DUNE_UNUSED_PARAMETER(len);
DUNE_UNUSED_PARAMETER(root);
return 0;
}
......@@ -319,9 +308,8 @@ namespace Dune
* @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise
*/
template<typename T>
int gather (const T* in, T* out, int len, int root) const // note out must have same size as in
int gather (const T* in, T* out, int len, [[maybe_unused]] int root) const // note out must have same size as in
{
DUNE_UNUSED_PARAMETER(root);
for (int i=0; i<len; i++)
out[i] = in[i];
return 0;
......@@ -357,10 +345,13 @@ namespace Dune
* @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise
*/
template<typename T>
int gatherv (const T* in, int sendlen, T* out, int* recvlen, int* displ, int root) const
int gatherv (const T* in,
int sendlen,
T* out,
[[maybe_unused]] int* recvlen,
int* displ,
[[maybe_unused]] int root) const
{
DUNE_UNUSED_PARAMETER(recvlen);
DUNE_UNUSED_PARAMETER(root);
for (int i=*displ; i<sendlen; i++)
out[i] = in[i];
return 0;
......@@ -380,9 +371,8 @@ namespace Dune
* @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise
*/
template<typename T>
int scatter (const T* send, T* recv, int len, int root) const // note out must have same size as in
int scatter (const T* send, T* recv, int len, [[maybe_unused]] int root) const // note out must have same size as in
{
DUNE_UNUSED_PARAMETER(root);
for (int i=0; i<len; i++)
recv[i] = send[i];
return 0;
......@@ -416,10 +406,9 @@ namespace Dune
* @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise
*/
template<typename T>
int scatterv (const T* send, int* sendlen, int* displ, T* recv, int recvlen, int root) const
int scatterv (const T* send, int* sendlen, int* displ, T* recv,
[[maybe_unused]] int recvlen, [[maybe_unused]] int root) const
{
DUNE_UNUSED_PARAMETER(recvlen);
DUNE_UNUSED_PARAMETER(root);
for (int i=*displ; i<*sendlen; i++)
recv[i] = send[i];
return 0;
......@@ -472,9 +461,8 @@ namespace Dune
* @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise
*/
template<typename T>
int allgatherv (const T* in, int sendlen, T* out, int* recvlen, int* displ) const
int allgatherv (const T* in, int sendlen, T* out, [[maybe_unused]] int* recvlen, int* displ) const
{
DUNE_UNUSED_PARAMETER(recvlen);
for (int i=*displ; i<sendlen; i++)
out[i] = in[i];
return 0;
......@@ -493,10 +481,8 @@ namespace Dune
* @returns MPI_SUCCESS (==0) if successful, an MPI error code otherwise
*/
template<typename BinaryFunction, typename Type>
int allreduce(Type* inout, int len) const
int allreduce([[maybe_unused]] Type* inout, [[maybe_unused]] int len) const
{
DUNE_UNUSED_PARAMETER(inout);
DUNE_UNUSED_PARAMETER(len);
return 0;
}
......
......@@ -18,7 +18,6 @@
#include <dune/common/parallel/interface.hh>
#include <dune/common/parallel/remoteindices.hh>
#include <dune/common/stdstreams.hh>
#include <dune/common/unused.hh>
namespace Dune
{
......@@ -906,10 +905,8 @@ namespace Dune
}
template<class V>
inline int CommPolicy<V>::getSize(const V& v, int index)
inline int CommPolicy<V>::getSize([[maybe_unused]] const V& v, [[maybe_unused]] int index)
{
DUNE_UNUSED_PARAMETER(v);
DUNE_UNUSED_PARAMETER(index);
return 1;
}
......@@ -1262,9 +1259,8 @@ namespace Dune
template<class Data, class GatherScatter, bool FORWARD>
inline void BufferedCommunicator::MessageGatherer<Data,GatherScatter,FORWARD,VariableSize>::operator()(const InterfaceMap& interfaces,const Data& data, Type* buffer, size_t bufferSize) const
inline void BufferedCommunicator::MessageGatherer<Data,GatherScatter,FORWARD,VariableSize>::operator()(const InterfaceMap& interfaces,const Data& data, Type* buffer, [[maybe_unused]] size_t bufferSize) const
{
DUNE_UNUSED_PARAMETER(bufferSize);
typedef typename InterfaceMap::const_iterator
const_iterator;
......@@ -1296,9 +1292,9 @@ namespace Dune
template<class Data, class GatherScatter, bool FORWARD>
inline void BufferedCommunicator::MessageGatherer<Data,GatherScatter,FORWARD,SizeOne>::operator()(const InterfaceMap& interfaces, const Data& data, Type* buffer, size_t bufferSize) const
inline void BufferedCommunicator::MessageGatherer<Data,GatherScatter,FORWARD,SizeOne>::operator()(
const InterfaceMap& interfaces, const Data& data, Type* buffer, [[maybe_unused]] size_t bufferSize) const
{
DUNE_UNUSED_PARAMETER(bufferSize);
typedef typename InterfaceMap::const_iterator
const_iterator;
const const_iterator end = interfaces.end();
......
......@@ -6,7 +6,6 @@
#include <algorithm>
#include <dune/common/arraylist.hh>
#include <dune/common/exceptions.hh>
#include <dune/common/unused.hh>
#include <iostream>
#include "localindex.hh"
......@@ -614,9 +613,8 @@ namespace Dune
template<typename T>
struct LocalIndexComparator
{
static bool compare(const T& t1, const T& t2){
DUNE_UNUSED_PARAMETER(t1);
DUNE_UNUSED_PARAMETER(t2);
static bool compare([[maybe_unused]] const T& t1, [[maybe_unused]] const T& t2)
{
return false;
}
};
......
......@@ -7,7 +7,6 @@
#include "remoteindices.hh"
#include <dune/common/stdstreams.hh>
#include <dune/common/sllist.hh>
#include <dune/common/unused.hh>
#include <cassert>
#include <cmath>
#include <limits>
......@@ -141,9 +140,8 @@ namespace Dune
* std::numeric_limits<size_t>::max()
* @param global The global index (ignored).
*/
std::size_t operator()(const GlobalIndex& global)
std::size_t operator()([[maybe_unused]] const GlobalIndex& global)
{
DUNE_UNUSED_PARAMETER(global);
return std::numeric_limits<size_t>::max();
}
};
......