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
ec4b7e9d
Commit
ec4b7e9d
authored
Jul 27, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some builtins to list
parent
785414ed
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
rt/include/python/builtins/list.hpp
rt/include/python/builtins/list.hpp
+28
-0
No files found.
rt/include/python/builtins/list.hpp
View file @
ec4b7e9d
...
@@ -8,6 +8,8 @@
...
@@ -8,6 +8,8 @@
#include <algorithm>
#include <algorithm>
#include <ostream>
#include <ostream>
#include <vector>
#include <vector>
//#include <nanobind/stl/detail/nb_list.h>
#include <pybind11/stl.h>
template
<
typename
T
>
class
PyList
{
template
<
typename
T
>
class
PyList
{
public:
public:
...
@@ -30,6 +32,18 @@ public:
...
@@ -30,6 +32,18 @@ public:
return
std
::
find
(
_v
->
begin
(),
_v
->
end
(),
x
)
!=
_v
->
end
();
return
std
::
find
(
_v
->
begin
(),
_v
->
end
(),
x
)
!=
_v
->
end
();
}
}
auto
size
()
const
{
return
_v
->
size
();
}
void
push_back
(
const
T
&
value
)
{
_v
->
push_back
(
value
);
}
void
clear
()
{
_v
->
clear
();
}
/*operator std::vector<T>() const {
/*operator std::vector<T>() const {
return std::vector<T>(this->begin(), this->end());
return std::vector<T>(this->begin(), this->end());
}
}
...
@@ -82,4 +96,18 @@ template <typename T> PyList<T> list(std::initializer_list<T> &&v) {
...
@@ -82,4 +96,18 @@ template <typename T> PyList<T> list(std::initializer_list<T> &&v) {
return
PyList
<
T
>
(
std
::
move
(
v
));
return
PyList
<
T
>
(
std
::
move
(
v
));
}
}
namespace
PYBIND11_NAMESPACE
{
namespace
detail
{
template
<
typename
Type
>
struct
type_caster
<
PyList
<
Type
>>
:
list_caster
<
PyList
<
Type
>
,
Type
>
{};
}}
/*NAMESPACE_BEGIN(NB_NAMESPACE)
NAMESPACE_BEGIN(detail)
template <typename Type> struct type_caster<PyList<Type>>
: list_caster<PyList<Type>, Type> { };
NAMESPACE_END(detail)
NAMESPACE_END(NB_NAMESPACE)
*/
#endif // TYPON_LIST_HPP
#endif // TYPON_LIST_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