Commit d71ae5a4 authored by Jacob Faibussowitsch's avatar Jacob Faibussowitsch
Browse files

source code format changes due to .clang-format changes

parent f78929e5
......@@ -106,29 +106,29 @@
Note that it does require <petscconf.h> to be included to obtain some properties of the system being built for
*/
#if defined(_WIN32) && defined(PETSC_USE_SHARED_LIBRARIES)
#define MPIUni_PETSC_DLLEXPORT __declspec(dllexport)
#define MPIUni_PETSC_DLLIMPORT __declspec(dllimport)
#define MPIUni_PETSC_DLLEXPORT __declspec(dllexport)
#define MPIUni_PETSC_DLLIMPORT __declspec(dllimport)
#elif defined(PETSC_USE_VISIBILITY_CXX) && defined(__cplusplus)
#define MPIUni_PETSC_DLLEXPORT __attribute__((visibility("default")))
#define MPIUni_PETSC_DLLIMPORT __attribute__((visibility("default")))
#define MPIUni_PETSC_DLLEXPORT __attribute__((visibility("default")))
#define MPIUni_PETSC_DLLIMPORT __attribute__((visibility("default")))
#elif defined(PETSC_USE_VISIBILITY_C) && !defined(__cplusplus)
#define MPIUni_PETSC_DLLEXPORT __attribute__((visibility("default")))
#define MPIUni_PETSC_DLLIMPORT __attribute__((visibility("default")))
#define MPIUni_PETSC_DLLEXPORT __attribute__((visibility("default")))
#define MPIUni_PETSC_DLLIMPORT __attribute__((visibility("default")))
#else
#define MPIUni_PETSC_DLLEXPORT
#define MPIUni_PETSC_DLLIMPORT
#define MPIUni_PETSC_DLLEXPORT
#define MPIUni_PETSC_DLLIMPORT
#endif
#if defined(petsc_EXPORTS)
#define MPIUni_PETSC_VISIBILITY_PUBLIC MPIUni_PETSC_DLLEXPORT
#define MPIUni_PETSC_VISIBILITY_PUBLIC MPIUni_PETSC_DLLEXPORT
#else /* Win32 users need this to import symbols from petsc.dll */
#define MPIUni_PETSC_VISIBILITY_PUBLIC MPIUni_PETSC_DLLIMPORT
#define MPIUni_PETSC_VISIBILITY_PUBLIC MPIUni_PETSC_DLLIMPORT
#endif
#if defined(__cplusplus)
#define MPIUni_PETSC_EXTERN extern "C" MPIUni_PETSC_VISIBILITY_PUBLIC
#define MPIUni_PETSC_EXTERN extern "C" MPIUni_PETSC_VISIBILITY_PUBLIC
#else
#define MPIUni_PETSC_EXTERN extern MPIUni_PETSC_VISIBILITY_PUBLIC
#define MPIUni_PETSC_EXTERN extern MPIUni_PETSC_VISIBILITY_PUBLIC
#endif
#if defined(__cplusplus)
......@@ -146,7 +146,7 @@ typedef unsigned long long MPIUNI_UINT64;
typedef _int64 MPIUNI_INT64;
typedef unsigned _int64 MPIUNI_UINT64;
#else
#error "Cannot determine MPIUNI_INT64, MPIUNI_UINT64 types"
#error "Cannot determine MPIUNI_INT64, MPIUNI_UINT64 types"
#endif
/*
......@@ -254,12 +254,12 @@ typedef int MPI_Datatype;
#define MPI_sizeof_default(datatype) ((((datatype) >> 8) & 0xfff) * ((datatype)&0xff))
#if defined(PETSC_USE_REAL___FP16)
MPIUni_PETSC_EXTERN MPI_Datatype MPIU___FP16;
#define MPI_sizeof(datatype) ((datatype == MPIU___FP16) ? (int)(2 * sizeof(char)) : MPI_sizeof_default(datatype))
#define MPI_sizeof(datatype) ((datatype == MPIU___FP16) ? (int)(2 * sizeof(char)) : MPI_sizeof_default(datatype))
#elif defined(PETSC_USE_REAL___FLOAT128)
MPIUni_PETSC_EXTERN MPI_Datatype MPIU___FLOAT128;
#define MPI_sizeof(datatype) ((datatype == MPIU___FLOAT128) ? (int)(2 * sizeof(double)) : MPI_sizeof_default(datatype))
#define MPI_sizeof(datatype) ((datatype == MPIU___FLOAT128) ? (int)(2 * sizeof(double)) : MPI_sizeof_default(datatype))
#else
#define MPI_sizeof(datatype) (MPI_sizeof_default(datatype))
#define MPI_sizeof(datatype) (MPI_sizeof_default(datatype))
#endif
MPIUni_PETSC_EXTERN int MPIUNI_Memcpy(void *, const void *, int);
......
#if !defined(__BAGIMPL)
#define __BAGIMPL
#include <petscbag.h>
#define __BAGIMPL
#include <petscbag.h>
#define PETSC_BAG_NAME_LENGTH 64
#define PETSC_BAG_HELP_LENGTH 128
#define PETSC_BAG_NAME_LENGTH 64
#define PETSC_BAG_HELP_LENGTH 128
struct _n_PetscBagItem {
PetscDataType dtype;
......
......@@ -51,7 +51,7 @@ struct _p_Characteristic {
PetscInt *velocityComp; /* Components of the velocity in the DM */
PetscErrorCode (*velocityInterp)(Vec, PetscReal[], PetscInt, PetscInt[], PetscScalar[], void *);
PetscErrorCode (*velocityInterpLocal)(void *, PetscReal[], PetscInt, PetscInt[], PetscScalar[], void *);
void *velocityCtx; /* User context for velocity inteprolation */
void *velocityCtx; /* User context for velocity inteprolation */
/* Field interpolation structures */
DM fieldDA; /* DM for the field field */
Vec field; /* Field field at t_n */
......@@ -60,7 +60,7 @@ struct _p_Characteristic {
PetscInt *fieldComp; /* Components of the field in the DM */
PetscErrorCode (*fieldInterp)(Vec, PetscReal[], PetscInt, PetscInt[], PetscScalar[], void *);
PetscErrorCode (*fieldInterpLocal)(void *, PetscReal[], PetscInt, PetscInt[], PetscScalar[], void *);
void *fieldCtx; /* User context for field inteprolation */
void *fieldCtx; /* User context for field inteprolation */
/* Communication structures*/
MPI_Datatype itemType; /* Type corresponding to the item struct */
Queue queue;
......
......@@ -2,17 +2,20 @@
#define PETSC_CPP_ARRAY_HPP
#if defined(__cplusplus)
#include <petsc/private/cpp/macros.hpp> // PETSC_DECLTYPE_NOEXCEPT_AUTO_RETURNS
#include <petsc/private/cpp/utility.hpp> // index_sequence
#include <petsc/private/cpp/type_traits.hpp>
#include <petsc/private/cpp/macros.hpp> // PETSC_DECLTYPE_NOEXCEPT_AUTO_RETURNS
#include <petsc/private/cpp/utility.hpp> // index_sequence
#include <petsc/private/cpp/type_traits.hpp>
#include <array>
#include <array>
namespace Petsc {
namespace Petsc
{
namespace util {
namespace util
{
namespace detail {
namespace detail
{
template <class D, class...>
struct return_type_helper {
......@@ -25,10 +28,12 @@ struct return_type_helper<void, T...> : std::common_type<T...> { };
template <class D, class... T>
using array_return_type = std::array<typename return_type_helper<D, T...>::type, sizeof...(T)>;
namespace {
namespace
{
template <typename T, std::size_t NL, std::size_t... IL, std::size_t NR, std::size_t... IR>
inline constexpr std::array<T, NL + NR> concat_array_impl(const std::array<T, NL> &l, const std::array<T, NR> &r, index_sequence<IL...>, index_sequence<IR...>) noexcept(std::is_nothrow_copy_constructible<T>::value) {
inline constexpr std::array<T, NL + NR> concat_array_impl(const std::array<T, NL> &l, const std::array<T, NR> &r, index_sequence<IL...>, index_sequence<IR...>) noexcept(std::is_nothrow_copy_constructible<T>::value)
{
return {l[IL]..., r[IR]...};
}
......@@ -36,10 +41,12 @@ inline constexpr std::array<T, NL + NR> concat_array_impl(const std::array<T, NL
} // namespace detail
namespace {
namespace
{
template <class D = void, class... T>
PETSC_NODISCARD inline constexpr detail::array_return_type<D, T...> make_array(T &&...t) noexcept(std::is_nothrow_constructible<detail::array_return_type<D, T...>>::value) {
PETSC_NODISCARD inline constexpr detail::array_return_type<D, T...> make_array(T &&...t) noexcept(std::is_nothrow_constructible<detail::array_return_type<D, T...>>::value)
{
return {std::forward<T>(t)...};
}
......
......@@ -3,9 +3,11 @@
#if defined(__cplusplus)
namespace Petsc {
namespace Petsc
{
namespace util {
namespace util
{
// A useful crtp helper class to abstract away all the static_cast<Derived *>(this) nonsense
template <typename T, template <typename> class CRTPType>
......
......@@ -2,18 +2,21 @@
#define PETSC_CPP_FUNCTIONAL_HPP
#if defined(__cplusplus)
#include <petsc/private/cpp/macros.hpp>
#include <petsc/private/cpp/utility.hpp> // index_sequence
#include <petsc/private/cpp/type_traits.hpp> // decay_t
#include <petsc/private/cpp/tuple.hpp> // tuple_element_t
#include <petsc/private/cpp/macros.hpp>
#include <petsc/private/cpp/utility.hpp> // index_sequence
#include <petsc/private/cpp/type_traits.hpp> // decay_t
#include <petsc/private/cpp/tuple.hpp> // tuple_element_t
#include <functional>
#include <functional>
namespace Petsc {
namespace Petsc
{
namespace util {
namespace util
{
namespace detail {
namespace detail
{
struct can_call_test {
template <typename F, typename... A>
......@@ -65,7 +68,8 @@ template <typename F, typename... A>
struct can_call : decltype(detail::can_call_test::f<F, A...>(0)) { };
template <typename... A, typename F>
inline constexpr can_call<F, A...> is_callable_with(F &&) noexcept {
inline constexpr can_call<F, A...> is_callable_with(F &&) noexcept
{
return can_call<F, A...>{};
}
......@@ -79,76 +83,78 @@ struct func_traits : detail::func_traits_impl<decay_t<T>> {
} // namespace Petsc
#define PETSC_ALIAS_FUNCTION_WITH_PROLOGUE_AND_EPILOGUE_(alias, original, dispatch, prologue, epilogue) \
template <typename... Args> \
static inline auto dispatch(int, Args &&...args) PETSC_DECLTYPE_NOEXCEPT_AUTO_RETURNS(original(std::forward<Args>(args)...)) template <typename... Args> \
static inline int dispatch(char, Args...) { \
using namespace Petsc::util; \
static_assert(is_callable_with<Args...>(original) && always_false<Args...>::value, "function " PetscStringize(original) "() is not callable with given arguments"); \
return EXIT_FAILURE; \
} \
template <typename... Args> \
PETSC_NODISCARD auto alias(Args &&...args) PETSC_DECLTYPE_NOEXCEPT_AUTO(dispatch(0, std::forward<Args>(args)...)) { \
prologue; \
auto ret = dispatch(0, std::forward<Args>(args)...); \
epilogue; \
return ret; \
}
#define PETSC_ALIAS_FUNCTION_(alias, original, dispatch) PETSC_ALIAS_FUNCTION_WITH_PROLOGUE_AND_EPILOGUE_(alias, original, dispatch, ((void)0), ((void)0))
#ifndef PetscConcat5
#define PetscConcat5_(a, b, c, d, e) a##b##c##d##e
#define PetscConcat5(a, b, c, d, e) PetscConcat5_(a, b, c, d, e)
#endif
// makes prefix_lineno_name
#define PETSC_ALIAS_UNIQUE_NAME_INTERNAL(prefix, name) PetscConcat5(prefix, _, __LINE__, _, name)
// PETSC_ALIAS_FUNCTION() - Alias a function
//
// input params:
// alias - the new name for the function
// original - the name of the function you would like to alias
//
// notes:
// Using this macro in effect creates
//
// template <typename... T>
// auto alias(T&&... args)
// {
// return original(std::forward<T>(args)...);
// }
//
// meaning it will transparently work for any kind of alias (including overloads).
//
// example usage:
// PETSC_ALIAS_FUNCTION(bar,foo);
#define PETSC_ALIAS_FUNCTION(alias, original) PETSC_ALIAS_FUNCTION_(alias, original, PETSC_ALIAS_UNIQUE_NAME_INTERNAL(PetscAliasFunctionDispatch, original))
// Similar to PETSC_ALIAS_FUNCTION() this macro creates a thin wrapper which passes all
// arguments to the target function ~except~ the last N arguments. So
//
// PETSC_ALIAS_FUNCTION_GOBBLE_NTH_ARGS(bar,foo,3);
//
// creates a function with the effect of
//
// returnType bar(argType1 arg1, argType2 arg2, ..., argTypeN argN)
// {
// IGNORE(argN);
// IGNORE(argN-1);
// IGNORE(argN-2);
// return foo(arg1,arg2,...,argN-3);
// }
//
// for you.
#define PETSC_ALIAS_FUNCTION_GOBBLE_NTH_LAST_ARGS_(alias, original, gobblefn, N) \
static_assert(std::is_integral<decltype(N)>::value && ((N) >= 0), ""); \
template <typename TupleT, std::size_t... idx> \
static inline auto gobblefn(TupleT &&tuple, Petsc::util::index_sequence<idx...>) PETSC_DECLTYPE_NOEXCEPT_AUTO_RETURNS(original(std::get<idx>(tuple)...)) template <typename... Args> \
PETSC_NODISCARD auto alias(Args &&...args) PETSC_DECLTYPE_NOEXCEPT_AUTO_RETURNS(gobblefn(std::forward_as_tuple(args...), Petsc::util::make_index_sequence<sizeof...(Args) - (N)>{}))
#define PETSC_ALIAS_FUNCTION_GOBBLE_NTH_LAST_ARGS(alias, original, N) PETSC_ALIAS_FUNCTION_GOBBLE_NTH_LAST_ARGS_(alias, original, PETSC_ALIAS_UNIQUE_NAME_INTERNAL(PetscAliasFunctionGobbleDispatch, original), N)
#define PETSC_ALIAS_FUNCTION_WITH_PROLOGUE_AND_EPILOGUE_(alias, original, dispatch, prologue, epilogue) \
template <typename... Args> \
static inline auto dispatch(int, Args &&...args) PETSC_DECLTYPE_NOEXCEPT_AUTO_RETURNS(original(std::forward<Args>(args)...)) template <typename... Args> \
static inline int dispatch(char, Args...) \
{ \
using namespace Petsc::util; \
static_assert(is_callable_with<Args...>(original) && always_false<Args...>::value, "function " PetscStringize(original) "() is not callable with given arguments"); \
return EXIT_FAILURE; \
} \
template <typename... Args> \
PETSC_NODISCARD auto alias(Args &&...args) PETSC_DECLTYPE_NOEXCEPT_AUTO(dispatch(0, std::forward<Args>(args)...)) \
{ \
prologue; \
auto ret = dispatch(0, std::forward<Args>(args)...); \
epilogue; \
return ret; \
}
#define PETSC_ALIAS_FUNCTION_(alias, original, dispatch) PETSC_ALIAS_FUNCTION_WITH_PROLOGUE_AND_EPILOGUE_(alias, original, dispatch, ((void)0), ((void)0))
#ifndef PetscConcat5
#define PetscConcat5_(a, b, c, d, e) a##b##c##d##e
#define PetscConcat5(a, b, c, d, e) PetscConcat5_(a, b, c, d, e)
#endif
// makes prefix_lineno_name
#define PETSC_ALIAS_UNIQUE_NAME_INTERNAL(prefix, name) PetscConcat5(prefix, _, __LINE__, _, name)
// PETSC_ALIAS_FUNCTION() - Alias a function
//
// input params:
// alias - the new name for the function
// original - the name of the function you would like to alias
//
// notes:
// Using this macro in effect creates
//
// template <typename... T>
// auto alias(T&&... args)
// {
// return original(std::forward<T>(args)...);
// }
//
// meaning it will transparently work for any kind of alias (including overloads).
//
// example usage:
// PETSC_ALIAS_FUNCTION(bar,foo);
#define PETSC_ALIAS_FUNCTION(alias, original) PETSC_ALIAS_FUNCTION_(alias, original, PETSC_ALIAS_UNIQUE_NAME_INTERNAL(PetscAliasFunctionDispatch, original))
// Similar to PETSC_ALIAS_FUNCTION() this macro creates a thin wrapper which passes all
// arguments to the target function ~except~ the last N arguments. So
//
// PETSC_ALIAS_FUNCTION_GOBBLE_NTH_ARGS(bar,foo,3);
//
// creates a function with the effect of
//
// returnType bar(argType1 arg1, argType2 arg2, ..., argTypeN argN)
// {
// IGNORE(argN);
// IGNORE(argN-1);
// IGNORE(argN-2);
// return foo(arg1,arg2,...,argN-3);
// }
//
// for you.
#define PETSC_ALIAS_FUNCTION_GOBBLE_NTH_LAST_ARGS_(alias, original, gobblefn, N) \
static_assert(std::is_integral<decltype(N)>::value && ((N) >= 0), ""); \
template <typename TupleT, std::size_t... idx> \
static inline auto gobblefn(TupleT &&tuple, Petsc::util::index_sequence<idx...>) PETSC_DECLTYPE_NOEXCEPT_AUTO_RETURNS(original(std::get<idx>(tuple)...)) template <typename... Args> \
PETSC_NODISCARD auto alias(Args &&...args) PETSC_DECLTYPE_NOEXCEPT_AUTO_RETURNS(gobblefn(std::forward_as_tuple(args...), Petsc::util::make_index_sequence<sizeof...(Args) - (N)>{}))
#define PETSC_ALIAS_FUNCTION_GOBBLE_NTH_LAST_ARGS(alias, original, N) PETSC_ALIAS_FUNCTION_GOBBLE_NTH_LAST_ARGS_(alias, original, PETSC_ALIAS_UNIQUE_NAME_INTERNAL(PetscAliasFunctionGobbleDispatch, original), N)
#endif // __cplusplus
......
......@@ -5,78 +5,80 @@
#if defined(__cplusplus)
// basic building blocks
#define PETSC_DECLTYPE_AUTO(...) ->decltype(__VA_ARGS__)
#define PETSC_NOEXCEPT_AUTO(...) noexcept(noexcept(__VA_ARGS__))
#define PETSC_RETURNS(...) \
{ return __VA_ARGS__; }
// basic building blocks
#define PETSC_DECLTYPE_AUTO(...) ->decltype(__VA_ARGS__)
#define PETSC_NOEXCEPT_AUTO(...) noexcept(noexcept(__VA_ARGS__))
#define PETSC_RETURNS(...) \
{ \
return __VA_ARGS__; \
}
// one without the other
#define PETSC_DECLTYPE_AUTO_RETURNS(...) PETSC_DECLTYPE_AUTO(__VA_ARGS__) PETSC_RETURNS(__VA_ARGS__)
#define PETSC_NOEXCEPT_AUTO_RETURNS(...) PETSC_NOEXCEPT_AUTO(__VA_ARGS__) PETSC_RETURNS(__VA_ARGS__)
// one without the other
#define PETSC_DECLTYPE_AUTO_RETURNS(...) PETSC_DECLTYPE_AUTO(__VA_ARGS__) PETSC_RETURNS(__VA_ARGS__)
#define PETSC_NOEXCEPT_AUTO_RETURNS(...) PETSC_NOEXCEPT_AUTO(__VA_ARGS__) PETSC_RETURNS(__VA_ARGS__)
// both
#define PETSC_DECLTYPE_NOEXCEPT_AUTO(...) PETSC_NOEXCEPT_AUTO(__VA_ARGS__) PETSC_DECLTYPE_AUTO(__VA_ARGS__)
// all
#define PETSC_DECLTYPE_NOEXCEPT_AUTO_RETURNS(...) PETSC_DECLTYPE_NOEXCEPT_AUTO(__VA_ARGS__) PETSC_RETURNS(__VA_ARGS__)
// both
#define PETSC_DECLTYPE_NOEXCEPT_AUTO(...) PETSC_NOEXCEPT_AUTO(__VA_ARGS__) PETSC_DECLTYPE_AUTO(__VA_ARGS__)
// all
#define PETSC_DECLTYPE_NOEXCEPT_AUTO_RETURNS(...) PETSC_DECLTYPE_NOEXCEPT_AUTO(__VA_ARGS__) PETSC_RETURNS(__VA_ARGS__)
// PETSC_CXX_COMPAT_DECL() - Helper macro to declare a C++ class member function or
// free-standing function guaranteed to be compatible with C
//
// input params:
// __VA_ARGS__ - the function declaration
//
// notes:
// Normally member functions of C++ structs or classes are not callable from C as they have an
// implicit "this" parameter tacked on the front (analogous to Pythons "self"). Static
// functions on the other hand do not have this restriction. This macro applies static to the
// function declaration as well as noexcept (as C++ exceptions escaping the C++ boundary is
// undefined behavior anyways) and [[nodiscard]].
//
// Note that the user should take care that function arguments and return type are also C
// compatible.
//
// example usage:
// class myclass
// {
// public:
// PETSC_CXX_COMPAT_DECL(PetscErrorCode foo(int,Vec,char));
// };
//
// use this to define inline as well
//
// class myclass
// {
// public:
// PETSC_CXX_COMPAT_DECL(PetscErrorCode foo(int a, Vec b, charc))
// {
// ...
// }
// };
//
// or to define a free-standing function
//
// PETSC_CXX_COMPAT_DECL(bool bar(int x, int y))
// {
// ...
// }
#define PETSC_CXX_COMPAT_DECL(...) PETSC_NODISCARD static inline __VA_ARGS__ noexcept
// PETSC_CXX_COMPAT_DECL() - Helper macro to declare a C++ class member function or
// free-standing function guaranteed to be compatible with C
//
// input params:
// __VA_ARGS__ - the function declaration
//
// notes:
// Normally member functions of C++ structs or classes are not callable from C as they have an
// implicit "this" parameter tacked on the front (analogous to Pythons "self"). Static
// functions on the other hand do not have this restriction. This macro applies static to the
// function declaration as well as noexcept (as C++ exceptions escaping the C++ boundary is
// undefined behavior anyways) and [[nodiscard]].
//
// Note that the user should take care that function arguments and return type are also C
// compatible.
//
// example usage:
// class myclass
// {
// public:
// PETSC_CXX_COMPAT_DECL(PetscErrorCode foo(int,Vec,char));
// };
//
// use this to define inline as well
//
// class myclass
// {
// public:
// PETSC_CXX_COMPAT_DECL(PetscErrorCode foo(int a, Vec b, charc))
// {
// ...
// }
// };
//
// or to define a free-standing function
//
// PETSC_CXX_COMPAT_DECL(bool bar(int x, int y))
// {
// ...
// }
#define PETSC_CXX_COMPAT_DECL(...) PETSC_NODISCARD static inline __VA_ARGS__ noexcept
// PETSC_CXX_COMPAT_DEFN() - Corresponding macro to define a C++ member function declared using
// PETSC_CXX_COMPAT_DECL()
//
// input params:
// __VA_ARGS__ - the function prototype (not the body!)
//
// notes:
// prepends inline and appends noexcept to the function
//
// example usage:
// PETSC_CXX_COMPAT_DEFN(PetscErrorCode myclass::foo(int a, Vec b, char c))
// {
// ...
// }
#define PETSC_CXX_COMPAT_DEFN(...) inline __VA_ARGS__ noexcept
// PETSC_CXX_COMPAT_DEFN() - Corresponding macro to define a C++ member function declared using
// PETSC_CXX_COMPAT_DECL()
//
// input params:
// __VA_ARGS__ - the function prototype (not the body!)
//
// notes:
// prepends inline and appends noexcept to the function
//
// example usage:
// PETSC_CXX_COMPAT_DEFN(PetscErrorCode myclass::foo(int a, Vec b, char c))
// {
// ...
// }
#define PETSC_CXX_COMPAT_DEFN(...) inline __VA_ARGS__ noexcept
#endif // __cplusplus
......
......@@ -6,18 +6,21 @@
#include <petsc/private/cpp/type_traits.hpp> // remove_extent
#if defined(__cplusplus)
#include <memory>
#include <new> // ::operator new(), ::operator delete()
#include <stack> // ... take a wild guess
#include <memory>
#include <new> // ::operator new(), ::operator delete()
#include <stack> // ... take a wild guess
namespace Petsc {
namespace Petsc
{
namespace util {
namespace util
{
#if PETSC_CPP_VERSION >= 14
#if PETSC_CPP_VERSION >= 14
using std::make_unique;
#else
namespace detail {
#else
namespace detail
{
// helpers shamelessly stolen from libcpp
template <class T>
......@@ -38,22 +41,25 @@ struct unique_if<T[N]> {
} // namespace detail
template <class T, class... Args>
inline typename detail::unique_if<T>::unique_single make_unique(Args &&...args) {
inline typename detail::unique_if<T>::unique_single make_unique(Args &&...args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
template <class T>
inline typename detail::unique_if<T>::unique_array_unknown_bound make_unique(std::size_t n) {
inline typename detail::unique_if<T>::unique_array_unknown_bound make_unique(std::size_t n)
{
return std::unique_ptr<T>(new util::remove_extent_t<T>[n]());
}
template <class T, class... Args>
typename detail::unique_if<T>::unique_array_known_bound make_unique(Args &&...) = delete;
#endif // PETSC_CPP_VERSION >= 14
#endif // PETSC_CPP_VERSION >= 14
} // namespace util
namespace memory {
namespace memory
{
class PoolAllocator : public RegisterFinalizeable<PoolAllocator> {
public:
......@@ -80,11 +86,13 @@ private:
inline PoolAllocator::PoolAllocator(size_type block_size) noexcept : block_size_(block_size), max_block_size_(block_size) { }
inline typename PoolAllocator::size_type PoolAllocator::block_size() const noexcept {
inline typename PoolAllocator::size_type PoolAllocator::block_size() const noexcept
{
return block_size_;
}
inline PetscErrorCode PoolAllocator::set_block_size(size_type block_size) noexcept {
inline PetscErrorCode PoolAllocator::set_block_size(size_type block_size) noexcept
{
PetscFunctionBegin;
if (PetscLikely(block_size == block_size_)) PetscFunctionReturn(0);
block_size_ = block_size;
......@@ -96,7 +104,8 @@ inline PetscErrorCode PoolAllocator::set_block_size(size_type block_size) noexce
PetscFunctionReturn(0);
}
inline PetscErrorCode PoolAllocator::allocate(void **ptr, size_type size) noexcept {
inline PetscErrorCode PoolAllocator::allocate(void **ptr, size_type size) noexcept
{
PetscFunctionBegin;
PetscValidPointer(ptr, 1);
*ptr = nullptr;
......@@ -111,7 +120,8 @@ inline PetscErrorCode PoolAllocator::allocate(void **ptr, size_type size) noexce
PetscFunctionReturn(0);
}
inline PetscErrorCode PoolAllocator::deallocate(void **ptr) noexcept {
inline PetscErrorCode PoolAllocator::deallocate(void **ptr) noexcept
{
PetscFunctionBegin;
PetscValidPointer(ptr, 1);
if (!*ptr) PetscFunctionReturn(0);
......@@ -127,7 +137,8 @@ inline PetscErrorCode PoolAllocator::deallocate(void **ptr) noexcept {
PetscFunctionReturn(0);
}
inline PetscErrorCode PoolAllocator::clear() noexcept {
inline PetscErrorCode PoolAllocator::clear() noexcept
{
PetscFunctionBegin;
while (!stack_.empty()) {