die.h 555 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // die.hpp
  3. // dice-roll
  4. //
  5. // Created by Sam Jaffe on 12/1/18.
  6. // Copyright © 2018 Sam Jaffe. All rights reserved.
  7. //
  8. #pragma once
  9. #include <boost/variant/variant.hpp>
  10. #include <iosfwd>
  11. #include <memory>
  12. namespace dice {
  13. struct dice;
  14. using sub_dice = boost::variant<int, std::shared_ptr<dice>>;
  15. // Default value: 1d1+0
  16. struct dice {
  17. int num{1};
  18. sub_dice of{1};
  19. sub_dice modifier{+0};
  20. };
  21. std::ostream & operator<<(std::ostream & out, dice const & d);
  22. std::istream & operator>>(std::istream & out, dice & d);
  23. }