Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions include/camp/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@

namespace camp
{
template <typename Tuple>
struct tuple_size;

///
/// Provides a portable std::array-like class.
///
Expand Down Expand Up @@ -284,6 +287,10 @@ CAMP_HOST_DEVICE constexpr void swap(array<T, N>& a, array<T, N>& b) noexcept(
a.swap(b);
}

template <typename T, size_t N>
struct tuple_size<array<T, N>> : ::camp::num<N> {
};

namespace detail
{
template <class T, std::size_t N, std::size_t... I>
Expand Down
1 change: 1 addition & 0 deletions include/camp/tuple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <sstream>
#include <type_traits>

#include "camp/array.hpp"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still seems backwards. tuple should be able to exist without knowing about array.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If array needs tuple_size from tuple.hpp, then just have array.hpp include tuple.hpp. But tuple should be able to stand alone independent of array.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really the base declaration of tuple_size and tuple_element should be in a separate header that both tuple.hpp and array.hpp could include.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is camp apply defined? That's what this is all about, is that in some higher level common header?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make more sense to change camp::apply to use std::tuple_size?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about two separate headers: one for traits common to both array and tuple (such as tuple_size), and another for common implementations (such as apply, invoke, etc..)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tuple_size isn't used in that many places, how about just using std::tuple_size as we should have been doing all along? We can make camp::tuple_size an alias for std::tuple_size.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I think something like that can work. My previous point was about moving camp's tuple_size and apply(...) to a separate header so that traits/methods that are common to both camp tuples and arrays don't live in tuple.hpp, but are instead included in there as well as array.hpp. Hopefully this would address the concerns that @adayton1 mentions above.

#include "camp/concepts.hpp"
#include "camp/map.hpp"

Expand Down