32 #ifndef Foam_stdFoam_H 33 #define Foam_stdFoam_H 36 #include <initializer_list> 39 #include <type_traits> 46 #if (__cplusplus >= 201402L) 47 # define FOAM_DEPRECATED(since) [[deprecated("Since " #since)]] 48 # define FOAM_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]] 49 # define FOAM_DEPRECATED_STRICT(since, replacement) [[deprecated("Since " #since "; use " #replacement)]] 50 #elif defined(__GNUC__) 51 # define FOAM_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) 52 # define FOAM_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) 53 # define FOAM_DEPRECATED_STRICT(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) 55 # define FOAM_DEPRECATED(since) 56 # define FOAM_DEPRECATED_FOR(since, replacement) 57 # define FOAM_DEPRECATED_STRICT(since, replacement) 59 #ifndef FOAM_COMPILE_STRICT 60 # undef FOAM_DEPRECATED_STRICT 61 # define FOAM_DEPRECATED_STRICT(since, replacement) 67 # define FOAM_NODISCARD __attribute__((warn_unused_result)) 69 # define FOAM_NODISCARD 95 return std::forward<T>(val);
102 return std::forward<T>(val);
121 template<
class T,
size_t N>
124 for (
size_t i = 0; i <
N; ++i)
154 constexpr
auto begin(
C&
c) -> decltype(
c.begin())
162 constexpr
auto begin(
const C&
c) -> decltype(
c.begin())
170 constexpr
auto cbegin(
const C&
c) -> decltype(
c.begin())
178 constexpr
auto end(
C&
c) -> decltype(
c.end())
186 constexpr
auto end(
const C&
c) -> decltype(
c.end())
194 constexpr
auto cend(
const C&
c) -> decltype(
c.end())
205 constexpr
auto rbegin(
C&
c) -> decltype(
c.rbegin())
213 constexpr
auto rbegin(
const C&
c) -> decltype(
c.rbegin())
221 constexpr
auto crbegin(
const C&
c) -> decltype(
c.rbegin())
229 constexpr
auto rend(
C&
c) -> decltype(
c.rend())
237 constexpr
auto rend(
const C&
c) -> decltype(
c.rend())
245 constexpr
auto crend(
const C&
c) -> decltype(
c.rend())
253 constexpr
inline const T&
min(
const T& a,
const T&
b)
255 return (
b < a) ?
b : a;
261 constexpr
inline const T&
max(
const T& a,
const T&
b)
263 return (a <
b) ?
b : a;
280 #define forAllIters(container,iter) \ 283 auto iter = stdFoam::begin(container); \ 284 iter != stdFoam::end(container); \ 298 #define forAllConstIters(container,iter) \ 301 auto iter = stdFoam::cbegin(container); \ 302 iter != stdFoam::cend(container); \ 317 #define forAllReverseIters(container,iter) \ 320 auto iter = stdFoam::rbegin(container); \ 321 iter != stdFoam::rend(container); \ 335 #define forAllConstReverseIters(container,iter) \ 338 auto iter = stdFoam::crbegin(container); \ 339 iter != stdFoam::crend(container); \ 353 #define forAll(list, i) \ 354 for (Foam::label i=0; i<(list).size(); ++i) 366 #define forAllReverse(list, i) \ 367 for (Foam::label i=(list).size()-1; i>=0; --i) 382 #define forAllIter(Container,container,iter) \ 385 Container::iterator iter = (container).begin(); \ 386 iter != (container).end(); \ 401 #define forAllConstIter(Container,container,iter) \ 404 Container::const_iterator iter = (container).cbegin(); \ 405 iter != (container).cend(); \ 501 constexpr
reference back()
const {
return *(data_ + size_ - 1); }
506 return *(data_ + idx);
521 return (size_*
sizeof(Type));
545 return span<Type>(data_ +
pos, size_ -
pos);
562 return reinterpret_cast<const char*
>(data_);
567 template<
class TypeT = Type>
568 typename std::enable_if<!std::is_const<TypeT>::value,
char*>
::type 571 return reinterpret_cast<char*
>(data_);
const Type & const_reference
constexpr T && operator[](T &&val) const noexcept
constexpr size_type size() const noexcept
Number of elements in the sequence.
constexpr auto crend(const C &c) -> decltype(c.rend())
Return const_reverse_iterator to reverse-end of container c.
constexpr auto crbegin(const C &c) -> decltype(c.rbegin())
Return const_reverse_iterator to the reverse-begin of container c.
std::remove_cv< Type > value_type
constexpr reference back() const
Access the last element. Undefined if span is empty.
~span() noexcept=default
Destructor.
constexpr span() noexcept
Default construct.
span< Type > subspan(size_type pos) const noexcept
Obtains a sub-span starting at pos until end of the sequence.
constexpr reference operator[](size_type idx) const
Access an element of the sequence.
constexpr pointer data() const noexcept
Return a pointer to the beginning of the sequence.
dimensionedScalar pos(const dimensionedScalar &ds)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
constexpr const T & max(const T &a, const T &b)
Return the greater of the parameters.
span< Type > first(size_type count) const noexcept
Obtains a span of the first count elements.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
const Type * const_pointer
std::ptrdiff_t difference_type
constexpr auto cend(const C &c) -> decltype(c.end())
Return const_iterator to the end of the container c.
graph_traits< Graph >::vertices_size_type size_type
constexpr bool empty() const noexcept
True if the sequence is empty.
std::enable_if<!std::is_const< TypeT >::value, char * >::type data_bytes() const noexcept
A writable view as byte content (if the pointer type is non-const). Like data(), the const access its...
constexpr size_type size_bytes() const noexcept
The size of the sequence in bytes.
A functor that returns its argument unchanged (cf. C++20 std::identity) Should never be specialized...
span & operator=(const span &other) noexcept=default
Copy assignment.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
constexpr auto cbegin(const C &c) -> decltype(c.begin())
Return const_iterator to the beginning of the container c.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
constexpr reference front() const
Access the first element. Undefined if span is empty.
const Vector< label > N(dict.get< Vector< label >>("N"))
constexpr auto rbegin(C &c) -> decltype(c.rbegin())
Return reverse_iterator to the reverse-begin of container c.
constexpr const T & min(const T &a, const T &b)
Return the lesser of the parameters.
const dimensionedScalar c
Speed of light in a vacuum.
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
Exchange contents of lists - see DynamicList::swap().
Rudimentary functionality similar to std::span for holding memory view.
constexpr iterator end() const noexcept
Iterator to one-past end of span.
constexpr auto rend(C &c) -> decltype(c.rend())
Return reverse_iterator to reverse-end of container c.
constexpr const char * cdata_bytes() const noexcept
A readonly view as byte content.
span< Type > last(size_type count) const noexcept
Obtains a span of the last count elements.
constexpr auto begin(C &c) -> decltype(c.begin())
Return iterator to the beginning of the container c.
constexpr iterator begin() const noexcept
Iterator to begin of span.
Namespace for std templates that are are part of future C++ standards or that are in a state of chang...
constexpr T && operator()(T &&val) const noexcept