Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

two more initializer list methods for generating views #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions include/andres/marray.hxx
Original file line number Diff line number Diff line change
@@ -355,9 +355,13 @@ public:
#ifdef HAVE_CPP11_INITIALIZER_LISTS
void view(std::initializer_list<std::size_t>,
std::initializer_list<std::size_t>, View<T, isConst, A>&) const;
View<T, isConst, A> view(std::initializer_list<std::size_t>,
std::initializer_list<std::size_t>) const;
void view(std::initializer_list<std::size_t>,
std::initializer_list<std::size_t>, const CoordinateOrder&,
View<T, isConst, A>&) const;
View<T, true, A> constView(std::initializer_list<std::size_t>,
std::initializer_list<std::size_t>) const;
void constView(std::initializer_list<std::size_t>,
std::initializer_list<std::size_t>, View<T, true, A>&) const;
void constView(std::initializer_list<std::size_t>,
@@ -2091,6 +2095,28 @@ View<T, isConst, A>::view
view(b.begin(), s.begin(), coordinateOrder(), out);
}


/// Get a sub-view with the same coordinate order.
///
/// \param b Initializer list coordinate sequence
/// that determines the start position of the sub-view.
/// \param s Initializer list coordinate sequence
/// that determines the stop position of the sub-view.
///
template<class T, bool isConst, class A>
inline View<T, isConst, A>
View<T, isConst, A>::view
(
std::initializer_list<std::size_t> b,
std::initializer_list<std::size_t> s
) const
{
View<T, isConst, A> out;
view(b.begin(), s.begin(), coordinateOrder(), out);
return out;
}


/// Get a sub-view to constant data.
///
/// \param b Initializer list coordinate sequence
@@ -2133,6 +2159,28 @@ View<T, isConst, A>::constView
{
constView(b.begin(), s.begin(), coordinateOrder(), out);
}

/// Get a sub-view to constant data with the same coordinate
/// order.
///
/// \param b Initializer list coordinate sequence
/// that determines the start position of the sub-view.
/// \param s Initializer list coordinate sequence
/// that determines the stop position of the sub-view.
/// \param out Sub-View (output).
///
template<class T, bool isConst, class A>
inline View<T, true, A>
View<T, isConst, A>::constView
(
std::initializer_list<std::size_t> b,
std::initializer_list<std::size_t> s
) const
{
View<T, true, A> out;
constView(b.begin(), s.begin(), coordinateOrder(), out);
return out;
}
#endif

/// Reshape the View.