fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class ParserResult
  5. {
  6. public:
  7. /// Default construction to invalid state (no initialization of storage required)
  8. ParserResult() : ray_header_{nullptr} {std:: cout << "Called ParserResult()" << std::endl;}
  9. ParserResult(ParserResult const &other) = default;
  10. ParserResult &operator=(ParserResult const &other) = default;
  11. ParserResult(ParserResult &&other) noexcept = default;
  12. ParserResult &operator=(ParserResult &&other) noexcept = default;
  13. ~ParserResult() = default;
  14.  
  15. /// Accessors to get the parsed ray view
  16. // auto getParsedRay() const
  17. // {
  18. // return ParsedRayView{ray_header_, e2e_trailer_, tcb::span<SitedChannelView const, MAX_NUM_SITED_CHANNELS>{sited_channel_storage(), MAX_NUM_SITED_CHANNELS}};
  19. // }
  20.  
  21. /// Accessors to get the number of bytes consumed from the raw data
  22. auto getNumBytesConsumed() const { return num_bytes_consumed_; }
  23.  
  24. public:
  25. uint32_t const *ray_header_;
  26. uint32_t const *e2e_trailer_;
  27.  
  28. /// The number of bytes consumed from the raw data
  29. std::size_t num_bytes_consumed_;
  30.  
  31. /// Uninitialized storage for sited channel views (avoids zeroing on construction)
  32. /// Valid items are populated by parsePacket and accessed via sited_channel_storage()
  33. // alignas(SitedChannelView) std::byte sited_channel_storage_raw_[sizeof(SitedChannelView) * MAX_NUM_SITED_CHANNELS];
  34.  
  35. /// Access storage as array of SitedChannelView (const)
  36. // SitedChannelView const *sited_channel_storage() const
  37. // {
  38. // return std::launder(reinterpret_cast<SitedChannelView const *>(sited_channel_storage_raw_));
  39. // }
  40.  
  41. // /// Access storage as array of SitedChannelView (mutable)
  42. // SitedChannelView *sited_channel_storage()
  43. // {
  44. // return std::launder(reinterpret_cast<SitedChannelView *>(sited_channel_storage_raw_));
  45. // }
  46.  
  47. /// Friends to set the member data
  48. // friend auto parsePacket(tcb::span<std::uint8_t const> const raw_data) -> ParserResult;
  49. // friend auto detail::makeParserResult(ParsedRayView const &parsed_ray, std::size_t const num_bytes_consumed) -> ParserResult;
  50. };
  51.  
  52. int main() {
  53. // your code goes here
  54. int x = 8;
  55. int y = 9;
  56. std::cout << x << y << std::endl;
  57. ParserResult result;
  58. std::cout << result.ray_header_ << " " << result.e2e_trailer_ << " " << result.num_bytes_consumed_ << std::endl;
  59. auto result2 = ParserResult{};
  60. std::cout << result2.ray_header_ << " " << result2.e2e_trailer_ << " " << result2.num_bytes_consumed_ << std::endl;
  61. return 0;
  62. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
89
Called ParserResult()
0  0x55c411e09435  22750966209312
Called ParserResult()
0  0x55c411e09260  140733763537712