IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 8f9236bc authored by ralfulrich's avatar ralfulrich
Browse files

fixed Stack enable_if

parent 7201a6b3
No related branches found
No related tags found
1 merge request!82Resolve "New stack interface doesn't build on OS X"
...@@ -117,13 +117,14 @@ namespace corsika::stack { ...@@ -117,13 +117,14 @@ namespace corsika::stack {
using T::GetStackData; using T::GetStackData;
public: public:
/*
template <typename... Args1, typename... Args2> template <typename... Args1, typename... Args2>
void SetParticleData(Args1... args1, Args2... args2) { void SetParticleData(Args1... args1, Args2... args2) {
T::SetParticleData(args1...); T::SetParticleData(args1...);
} }
template <typename... Args1, typename... Args2> template <typename... Args1, typename... Args2>
void SetParticleData(T& p, Args1... args1, Args2... args2) {} void SetParticleData(T& p, Args1... args1, Args2... args2) {}
*/
}; };
} // namespace corsika::stack } // namespace corsika::stack
......
...@@ -67,11 +67,17 @@ namespace corsika::stack { ...@@ -67,11 +67,17 @@ namespace corsika::stack {
delete; ///< since Stack can be very big, we don't want to copy it delete; ///< since Stack can be very big, we don't want to copy it
public: public:
//Stack() { Init(); }
/** /**
* if StackDataType is a reference member we *have* to initialize * if StackDataType is a reference member we *HAVE* to initialize
* it in the constructor, this is typically needed for SecondaryView * it in the constructor, this is typically needed for SecondaryView
*/ */
template <typename = std::enable_if_t<std::is_reference<StackDataType>{}>> template <
typename _StackDataType = StackDataType,
typename = std::enable_if<std::is_same<StackDataType, _StackDataType>::value &&
std::is_reference<_StackDataType>::value,
void>>
Stack(StackDataType vD) Stack(StackDataType vD)
: fData(vD) {} : fData(vD) {}
...@@ -80,8 +86,11 @@ namespace corsika::stack { ...@@ -80,8 +86,11 @@ namespace corsika::stack {
* StackDataType user class. If the user did not provide a suited * StackDataType user class. If the user did not provide a suited
* constructor this will fail with an error message. * constructor this will fail with an error message.
*/ */
template <typename... Args, template <
typename = std::enable_if_t<!std::is_reference<StackDataType>{}>> typename... Args, typename _StackDataType = StackDataType,
typename = std::enable_if<std::is_same<StackDataType, _StackDataType>::value &&
!std::is_reference<_StackDataType>::value,
void >>
Stack(Args... args) Stack(Args... args)
: fData(args...) {} : fData(args...) {}
......
...@@ -33,7 +33,6 @@ using namespace corsika::stack; ...@@ -33,7 +33,6 @@ using namespace corsika::stack;
using namespace std; using namespace std;
typedef Stack<TestStackData, TestParticleInterface> StackTest; typedef Stack<TestStackData, TestParticleInterface> StackTest;
typedef StackTest::ParticleInterfaceType Particle;
TEST_CASE("Stack", "[Stack]") { TEST_CASE("Stack", "[Stack]") {
...@@ -48,7 +47,6 @@ TEST_CASE("Stack", "[Stack]") { ...@@ -48,7 +47,6 @@ TEST_CASE("Stack", "[Stack]") {
// construct a valid Stack object // construct a valid Stack object
StackTest s; StackTest s;
s.Init();
s.Clear(); s.Clear();
s.AddParticle(std::tuple{0.}); s.AddParticle(std::tuple{0.});
s.Copy(s.cbegin(), s.begin()); s.Copy(s.cbegin(), s.begin());
...@@ -98,7 +96,7 @@ TEST_CASE("Stack", "[Stack]") { ...@@ -98,7 +96,7 @@ TEST_CASE("Stack", "[Stack]") {
StackTest s; StackTest s;
REQUIRE(s.GetSize() == 0); REQUIRE(s.GetSize() == 0);
auto iter = s.AddParticle(std::tuple{9.9}); auto iter = s.AddParticle(std::tuple{9.9});
Particle& p = *iter; // also this is valid to access particle data StackTest::ParticleInterfaceType& p = *iter; // also this is valid to access particle data
REQUIRE(s.GetSize() == 1); REQUIRE(s.GetSize() == 1);
p.AddSecondary(std::tuple{4.4}); p.AddSecondary(std::tuple{4.4});
REQUIRE(s.GetSize() == 2); REQUIRE(s.GetSize() == 2);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment