Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon-compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
typon
typon-compiler
Commits
49c9e5f1
Commit
49c9e5f1
authored
Jul 07, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorder items in print.hpp to fix template lookup
parent
c2cf0423
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
28 deletions
+23
-28
rt/include/python/builtins/print.hpp
rt/include/python/builtins/print.hpp
+23
-28
No files found.
rt/include/python/builtins/print.hpp
View file @
49c9e5f1
...
...
@@ -8,8 +8,8 @@
#include <iostream>
#include <ostream>
#include <typon/typon.hpp>
#include "str.hpp"
#include <typon/typon.hpp>
template
<
typename
T
>
concept
Streamable
=
requires
(
const
T
&
x
,
std
::
ostream
&
s
)
{
...
...
@@ -19,6 +19,22 @@ concept Streamable = requires(const T &x, std::ostream &s) {
template
<
Streamable
T
>
void
print_to
(
const
T
&
x
,
std
::
ostream
&
s
)
{
s
<<
x
;
}
template
<
Streamable
T
>
void
repr_to
(
const
T
&
x
,
std
::
ostream
&
s
)
{
s
<<
x
;
}
template
<
typename
T
>
concept
PyPrint
=
requires
(
const
T
&
x
,
std
::
ostream
&
s
)
{
{
x
.
py_print
(
s
)
}
->
std
::
same_as
<
void
>
;
};
template
<
PyPrint
T
>
void
print_to
(
const
T
&
x
,
std
::
ostream
&
s
)
{
x
.
py_print
(
s
);
}
template
<
typename
T
>
concept
PyRepr
=
requires
(
const
T
&
x
,
std
::
ostream
&
s
)
{
{
x
.
py_repr
(
s
)
}
->
std
::
same_as
<
void
>
;
};
template
<
PyRepr
T
>
void
repr_to
(
const
T
&
x
,
std
::
ostream
&
s
)
{
x
.
py_repr
(
s
);
}
template
<
typename
T
>
concept
Printable
=
requires
(
const
T
&
x
,
std
::
ostream
&
s
)
{
{
print_to
(
x
,
s
)
}
->
std
::
same_as
<
void
>
;
...
...
@@ -35,53 +51,32 @@ concept FunctionPointer =
std
::
is_function_v
<
std
::
remove_pointer_t
<
T
>>
;
template
<
Streamable
T
>
requires
(
FunctionPointer
<
T
>
)
requires
(
FunctionPointer
<
T
>
)
void
repr_to
(
const
T
&
x
,
std
::
ostream
&
s
)
{
s
<<
"<function at 0x"
<<
std
::
hex
<<
(
size_t
)
x
<<
std
::
dec
<<
">"
;
}
template
<
>
void
repr_to
(
const
PyStr
&
x
,
std
::
ostream
&
s
)
{
template
<
>
void
repr_to
(
const
PyStr
&
x
,
std
::
ostream
&
s
)
{
s
<<
'"'
<<
x
<<
'"'
;
}
template
<
Streamable
T
>
requires
(
Reprable
<
T
>
)
requires
(
Reprable
<
T
>
)
void
print_to
(
const
T
&
x
,
std
::
ostream
&
s
)
{
repr_to
(
x
,
s
);
}
template
<
typename
T
>
concept
PyPrint
=
requires
(
const
T
&
x
,
std
::
ostream
&
s
)
{
{
x
.
py_print
(
s
)
}
->
std
::
same_as
<
void
>
;
};
template
<
PyPrint
T
>
void
print_to
(
const
T
&
x
,
std
::
ostream
&
s
)
{
x
.
py_print
(
s
);
}
template
<
typename
T
>
concept
PyRepr
=
requires
(
const
T
&
x
,
std
::
ostream
&
s
)
{
{
x
.
py_repr
(
s
)
}
->
std
::
same_as
<
void
>
;
};
template
<
PyRepr
T
>
void
repr_to
(
const
T
&
x
,
std
::
ostream
&
s
)
{
x
.
py_repr
(
s
);
}
template
<
Printable
T
>
void
print_to
(
const
std
::
shared_ptr
<
T
>
&
x
,
std
::
ostream
&
s
)
{
print_to
(
*
x
,
s
);
}
template
<
Print
able
T
>
template
<
Repr
able
T
>
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
<
>
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) {
...
...
@@ -100,5 +95,5 @@ struct {
std
::
cout
<<
'\n'
;
}
}
print
;
//typon::Task<void> print() { std::cout << '\n'; co_return; }
//
typon::Task<void> print() { std::cout << '\n'; co_return; }
#endif // TYPON_PRINT_HPP
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment