
#ifndef PLS_ALIGNED_STACK_IMPL_H
#define PLS_ALIGNED_STACK_IMPL_H

#include <utility>

namespace pls {
namespace internal {
namespace data_structures {

template<typename T, typename ...ARGS>
T *aligned_stack::push(ARGS &&... args) {
  // Perfect-Forward construct
  return new(push_bytes<T>())T(std::forward<ARGS>(args)...);
}

template<typename T>
void *aligned_stack::push_bytes() {
  return push_bytes(sizeof(T));
}

template<typename T>
T aligned_stack::pop() {
  head_ = head_ - base::alignment::next_alignment(sizeof(T));
  return *reinterpret_cast<T *>(head_);
}

}
}
}

#endif //PLS_ALIGNED_STACK_IMPL_H
