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 #elif defined(__GNUC__) 50 # define FOAM_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) 51 # define FOAM_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) 53 # define FOAM_DEPRECATED(since) 54 # define FOAM_DEPRECATED_FOR(since, replacement) 60 # define FOAM_NODISCARD __attribute__((warn_unused_result)) 62 # define FOAM_NODISCARD 81 using std::unique_ptr;
93 return std::forward<T>(val);
112 template<
class T,
size_t N>
115 for (
size_t i = 0; i <
N; ++i)
145 constexpr
auto begin(
C&
c) -> decltype(
c.begin())
153 constexpr
auto begin(
const C&
c) -> decltype(
c.begin())
161 constexpr
auto cbegin(
const C&
c) -> decltype(
c.begin())
169 constexpr
auto end(
C&
c) -> decltype(
c.end())
177 constexpr
auto end(
const C&
c) -> decltype(
c.end())
185 constexpr
auto cend(
const C&
c) -> decltype(
c.end())
196 constexpr
auto rbegin(
C&
c) -> decltype(
c.rbegin())
204 constexpr
auto rbegin(
const C&
c) -> decltype(
c.rbegin())
212 constexpr
auto crbegin(
const C&
c) -> decltype(
c.rbegin())
220 constexpr
auto rend(
C&
c) -> decltype(
c.rend())
228 constexpr
auto rend(
const C&
c) -> decltype(
c.rend())
236 constexpr
auto crend(
const C&
c) -> decltype(
c.rend())
244 constexpr
inline const T&
min(
const T& a,
const T&
b)
246 return (
b < a) ?
b : a;
252 constexpr
inline const T&
max(
const T& a,
const T&
b)
254 return (a <
b) ?
b : a;
271 #define forAllIters(container,iter) \ 274 auto iter = stdFoam::begin(container); \ 275 iter != stdFoam::end(container); \ 289 #define forAllConstIters(container,iter) \ 292 auto iter = stdFoam::cbegin(container); \ 293 iter != stdFoam::cend(container); \ 308 #define forAllReverseIters(container,iter) \ 311 auto iter = stdFoam::rbegin(container); \ 312 iter != stdFoam::rend(container); \ 326 #define forAllConstReverseIters(container,iter) \ 329 auto iter = stdFoam::crbegin(container); \ 330 iter != stdFoam::crend(container); \ 344 #define forAll(list, i) \ 345 for (Foam::label i=0; i<(list).size(); ++i) 357 #define forAllReverse(list, i) \ 358 for (Foam::label i=(list).size()-1; i>=0; --i) 373 #define forAllIter(Container,container,iter) \ 376 Container::iterator iter = (container).begin(); \ 377 iter != (container).end(); \ 392 #define forAllConstIter(Container,container,iter) \ 395 Container::const_iterator iter = (container).cbegin(); \ 396 iter != (container).cend(); \ 492 constexpr
reference back()
const {
return *(data_ + size_ - 1); }
497 return *(data_ + idx);
512 return (size_*
sizeof(Type));
536 return span<Type>(data_ +
pos, size_ -
pos);
553 return reinterpret_cast<const char*
>(data_);
558 template<
class TypeT = Type>
559 typename std::enable_if<!std::is_const<TypeT>::value,
char*>
::type 562 return reinterpret_cast<char*
>(data_);
Graphite solid properties.
const Type & const_reference
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)
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