Commit 578ab3c4 authored by Tom Niget's avatar Tom Niget

Fix include cycle

parent 98ffcdd9
......@@ -8,7 +8,6 @@
#include <iostream>
#include <ostream>
#include <functional>
#include "str.hpp"
#include <typon/typon.hpp>
template <typename T>
......@@ -62,10 +61,6 @@ void repr_to(const std::function<T> &x, std::ostream &s) {
<< ">";
}
template <> void repr_to(const PyStr &x, std::ostream &s) {
s << '"' << x << '"';
}
template <Streamable T>
requires(Reprable<T>)
void print_to(const T &x, std::ostream &s) {
......@@ -82,7 +77,6 @@ void repr_to(const std::shared_ptr<T> &x, std::ostream &s) {
repr_to(*x, s);
}
template <> void print_to<PyStr>(const PyStr &x, std::ostream &s) { s << x; }
/*
template <Printable T, Printable... Args>
typon::Task<void> print(T const &head, Args const &...args) {
......@@ -103,13 +97,6 @@ struct {
} print;
// typon::Task<void> print() { std::cout << '\n'; co_return; }
struct {
PyStr operator()(const PyStr& s = ""_ps) {
std::cout << s;
PyStr input;
std::getline(std::cin, input);
return input;
}
} input;
#endif // TYPON_PRINT_HPP
......@@ -16,6 +16,7 @@ using namespace std::literals;
#include "slice.hpp"
// #include <format>
#include <fmt/format.h>
#include <pybind11/cast.h>
class PyStr : public std::string {
public:
......@@ -119,7 +120,7 @@ template <typename T> PyStr str(const T &x) {
template <typename T> PyStr repr(const T &x) {
std::stringstream s;
repr_to(x, s);
::repr_to(x, s);
return s.str();
}
......@@ -129,4 +130,26 @@ template <> struct std::hash<PyStr> {
}
};
namespace PYBIND11_NAMESPACE {
namespace detail {
template<>
struct type_caster<PyStr>
: string_caster<PyStr> {};
}}
template <> void repr_to(const PyStr &x, std::ostream &s) {
s << '"' << x << '"';
}
template <> void print_to<PyStr>(const PyStr &x, std::ostream &s) { s << x; }
struct {
PyStr operator()(const PyStr& s = ""_ps) {
std::cout << s;
PyStr input;
std::getline(std::cin, input);
return input;
}
} input;
#endif // TYPON_STR_HPP
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment