forked from AMReX-Codes/amrex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'AMReX-Codes:development' into eyoo/multicuts
- Loading branch information
Showing
10 changed files
with
139 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#ifndef AMREX_IO_FORMAT_H_ | ||
#define AMREX_IO_FORMAT_H_ | ||
|
||
#include <ios> | ||
|
||
namespace amrex { | ||
|
||
/* | ||
* \brief I/O stream format saver | ||
* | ||
* This class can be used to save and restore I/O stream format in a RAII | ||
* way. It handles fill, fmtflag, precision, and width. | ||
*/ | ||
template <class CharT, class Traits> | ||
class IOFormatSaver | ||
{ | ||
public: | ||
using BasicIos = std::basic_ios<CharT, Traits>; | ||
|
||
explicit IOFormatSaver (BasicIos& ios) | ||
: m_ios(&ios), | ||
m_fill(ios.fill()), | ||
m_flags(ios.flags()), | ||
m_precision(ios.precision()), | ||
m_width(ios.width()) | ||
{} | ||
|
||
~IOFormatSaver () | ||
{ | ||
m_ios->fill(m_fill); | ||
m_ios->flags(m_flags); | ||
m_ios->precision(m_precision); | ||
m_ios->width(m_width); | ||
} | ||
|
||
IOFormatSaver (IOFormatSaver const&) = delete; | ||
IOFormatSaver (IOFormatSaver &&) noexcept = delete; | ||
IOFormatSaver& operator= (IOFormatSaver const&) = delete; | ||
IOFormatSaver& operator= (IOFormatSaver &&) noexcept = delete; | ||
|
||
private: | ||
BasicIos* m_ios; | ||
CharT m_fill; | ||
typename BasicIos::fmtflags m_flags; | ||
std::streamsize m_precision; | ||
std::streamsize m_width; | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef AMREX_STACK_H_ | ||
#define AMREX_STACK_H_ | ||
|
||
namespace amrex { | ||
|
||
template <typename T, int N> | ||
struct Stack | ||
{ | ||
public: | ||
constexpr void push (T v) { m_data[m_size++] = v; } | ||
constexpr void pop () { --m_size; } | ||
[[nodiscard]] constexpr bool empty () const { return m_size == 0; } | ||
[[nodiscard]] constexpr int size () const { return m_size; } | ||
[[nodiscard]] constexpr T const& top () const { return m_data[m_size-1]; } | ||
[[nodiscard]] constexpr T & top () { return m_data[m_size-1]; } | ||
[[nodiscard]] constexpr T operator[] (int i) const { return m_data[i]; } | ||
private: | ||
T m_data[N]; | ||
int m_size = 0; | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters