forwards.h 772 B

1234567891011121314151617181920212223242526272829303132
  1. //
  2. // forwards.h
  3. // string-utils
  4. //
  5. // Created by Sam Jaffe on 6/12/22.
  6. // Copyright © 2022 Sam Jaffe. All rights reserved.
  7. //
  8. #pragma once
  9. #include "string_utils/traits.h"
  10. namespace string_utils {
  11. class Tokenizer;
  12. class EscapedTokenizer;
  13. // A helper object for providing partial specializations for casting
  14. template <typename, typename = void> struct cast_helper;
  15. // The main parser
  16. template <typename T> std::pair<T, bool> cast(std::string_view str) noexcept;
  17. template <typename T, typename S>
  18. std::pair<T, bool> cast(std::vector<S> const & str) noexcept;
  19. template <
  20. typename S, typename T,
  21. typename = std::enable_if_t<detail::has_result<cast_helper<T>(S, T &)>{}>>
  22. bool cast(S const & str, T & to) noexcept {
  23. return cast_helper<T>{}(str, to);
  24. }
  25. }