Skip to content

Commit

Permalink
noexcept details for MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Mar 5, 2024
1 parent 7218b02 commit 929b594
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
17 changes: 12 additions & 5 deletions include/openPMD/snapshots/ContainerImpls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ class StatefulSnapshotsContainer : public AbstractSnapshotsContainer
{
private:
friend class Series;
std::function<StatefulIterator *()> m_begin;
StatefulSnapshotsContainer(std::function<StatefulIterator *()> begin);

std::optional<StatefulIterator *> m_bufferedIterator = std::nullopt;
struct Members
{
std::function<StatefulIterator *()> m_begin;
std::optional<StatefulIterator *> m_bufferedIterator = std::nullopt;
};
Members members;

StatefulSnapshotsContainer(std::function<StatefulIterator *()> begin);

auto get() -> StatefulIterator *;
auto get() const -> StatefulIterator const *;
Expand All @@ -23,12 +28,14 @@ class StatefulSnapshotsContainer : public AbstractSnapshotsContainer
~StatefulSnapshotsContainer() override;

StatefulSnapshotsContainer(StatefulSnapshotsContainer const &other);
StatefulSnapshotsContainer(StatefulSnapshotsContainer &&other) noexcept;
StatefulSnapshotsContainer(StatefulSnapshotsContainer &&other) noexcept(
noexcept(Members(std::declval<Members &&>())));

StatefulSnapshotsContainer &
operator=(StatefulSnapshotsContainer const &other);
StatefulSnapshotsContainer &
operator=(StatefulSnapshotsContainer &&other) noexcept;
operator=(StatefulSnapshotsContainer &&other) noexcept(noexcept(
std::declval<Members>().operator=(std::declval<Members &&>())));

auto currentIteration() -> std::optional<value_type *> override;
auto currentIteration() const -> std::optional<value_type const *> override;
Expand Down
19 changes: 11 additions & 8 deletions src/snapshots/ContainerImpls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,32 @@ namespace

StatefulSnapshotsContainer::StatefulSnapshotsContainer(
std::function<StatefulIterator *()> begin)
: m_begin(std::move(begin))
: members{std::move(begin)}
{}

StatefulSnapshotsContainer::StatefulSnapshotsContainer(
StatefulSnapshotsContainer const &other) = default;
StatefulSnapshotsContainer::StatefulSnapshotsContainer(
StatefulSnapshotsContainer &&other) noexcept = default;
StatefulSnapshotsContainer
&&other) noexcept(noexcept(Members(std::declval<Members &&>()))) =
default;
StatefulSnapshotsContainer &StatefulSnapshotsContainer::operator=(
StatefulSnapshotsContainer const &other) = default;
StatefulSnapshotsContainer &StatefulSnapshotsContainer::operator=(
StatefulSnapshotsContainer &&other) noexcept = default;
StatefulSnapshotsContainer &StatefulSnapshotsContainer::
operator=(StatefulSnapshotsContainer &&other) noexcept(noexcept(
std::declval<Members>().operator=(std::declval<Members &&>()))) = default;

auto StatefulSnapshotsContainer::get() -> StatefulIterator *
{
if (!m_bufferedIterator.has_value())
if (!members.m_bufferedIterator.has_value())
{
m_bufferedIterator = m_begin();
members.m_bufferedIterator = members.m_begin();
}
return *m_bufferedIterator;
return *members.m_bufferedIterator;
}
auto StatefulSnapshotsContainer::get() const -> StatefulIterator const *
{
return m_bufferedIterator.value_or(nullptr);
return members.m_bufferedIterator.value_or(nullptr);
}
auto StatefulSnapshotsContainer::currentIteration()
-> std::optional<value_type *>
Expand Down

0 comments on commit 929b594

Please sign in to comment.