Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polymesh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Philip Trettner
polymesh
Commits
2ee20575
Commit
2ee20575
authored
4 years ago
by
Philip Trettner
Browse files
Options
Downloads
Patches
Plain Diff
fixed attribute views
parent
85dc7a41
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/polymesh/attributes.hh
+5
-3
5 additions, 3 deletions
src/polymesh/attributes.hh
src/polymesh/impl/impl_attributes.hh
+8
-1
8 additions, 1 deletion
src/polymesh/impl/impl_attributes.hh
src/polymesh/view.hh
+14
-8
14 additions, 8 deletions
src/polymesh/view.hh
with
27 additions
and
12 deletions
src/polymesh/attributes.hh
+
5
−
3
View file @
2ee20575
...
...
@@ -108,11 +108,13 @@ public:
void
compute
(
FuncT
&&
f
);
template
<
class
FuncT
>
auto
view
(
FuncT
&&
f
)
const
->
attribute_view
<
primitive_attribute
<
tag
,
AttrT
>
const
&
,
FuncT
>
;
#ifndef _MSC_VER // cannot overload this apparently
auto
view
(
FuncT
&&
f
)
&
->
attribute_view
<
primitive_attribute
<
tag
,
AttrT
>&
,
FuncT
>
;
template
<
class
FuncT
>
auto
view
(
FuncT
&&
f
)
const
&
->
attribute_view
<
primitive_attribute
<
tag
,
AttrT
>
const
&
,
FuncT
>
;
template
<
class
FuncT
>
void
view
(
FuncT
&&
f
)
&&
=
delete
;
#endif
template
<
class
FuncT
>
void
view
(
FuncT
&&
f
)
const
&&
=
delete
;
// template <class ReadT, class WriteT>
// auto view(ReadT&& r, WriteT&& w) -> readwrite_property<primitive_attribute<tag, AttrT>, ReadT, WriteT>;
...
...
This diff is collapsed.
Click to expand it.
src/polymesh/impl/impl_attributes.hh
+
8
−
1
View file @
2ee20575
...
...
@@ -439,9 +439,16 @@ void primitive_attribute<tag, AttrT>::compute(FuncT&& f)
template
<
class
tag
,
class
AttrT
>
template
<
class
FuncT
>
auto
primitive_attribute
<
tag
,
AttrT
>::
view
(
FuncT
&&
f
)
const
->
attribute_view
<
primitive_attribute
<
tag
,
AttrT
>
const
&
,
FuncT
>
auto
primitive_attribute
<
tag
,
AttrT
>::
view
(
FuncT
&&
f
)
const
&
->
attribute_view
<
primitive_attribute
<
tag
,
AttrT
>
const
&
,
FuncT
>
{
return
attribute_view
<
primitive_attribute
<
tag
,
AttrT
>
const
&
,
FuncT
>
(
*
this
,
std
::
forward
<
FuncT
>
(
f
));
}
template
<
class
tag
,
class
AttrT
>
template
<
class
FuncT
>
auto
primitive_attribute
<
tag
,
AttrT
>::
view
(
FuncT
&&
f
)
&
->
attribute_view
<
primitive_attribute
<
tag
,
AttrT
>&
,
FuncT
>
{
return
attribute_view
<
primitive_attribute
<
tag
,
AttrT
>&
,
FuncT
>
(
*
this
,
std
::
forward
<
FuncT
>
(
f
));
}
}
// namespace polymesh
This diff is collapsed.
Click to expand it.
src/polymesh/view.hh
+
14
−
8
View file @
2ee20575
...
...
@@ -8,30 +8,36 @@ namespace polymesh
template
<
class
CollectionT
,
class
FuncT
>
struct
attribute_view
{
attribute_view
(
CollectionT
collection
,
FuncT
func
)
:
mCollection
(
collection
),
mFunc
(
std
::
move
(
func
))
{}
attribute_view
(
CollectionT
&
collection
,
FuncT
func
)
:
mCollection
(
collection
),
mFunc
(
std
::
move
(
func
))
{}
using
index_t
=
typename
std
::
decay
<
CollectionT
>::
type
::
index_t
;
using
handle_t
=
typename
std
::
decay
<
CollectionT
>::
type
::
handle_t
;
using
input_t
=
decltype
(
std
::
declval
<
CollectionT
>
()[
index_t
()]);
using
output_t
=
typename
tmp
::
decayed_result_type_of
<
FuncT
,
input_t
>
;
output_t
operator
[](
handle_t
h
)
const
{
return
mFunc
(
mCollection
(
h
));
}
output_t
operator
[](
index_t
h
)
const
{
return
mFunc
(
mCollection
(
h
));
}
decltype
(
auto
)
operator
[](
handle_t
h
)
const
{
return
mFunc
(
mCollection
(
h
));
}
decltype
(
auto
)
operator
[](
index_t
h
)
const
{
return
mFunc
(
mCollection
(
h
));
}
output_t
operator
()(
handle_t
h
)
const
{
return
mFunc
(
mCollection
(
h
));
}
output_t
operator
()(
index_t
h
)
const
{
return
mFunc
(
mCollection
(
h
));
}
decltype
(
auto
)
operator
()(
handle_t
h
)
const
{
return
mFunc
(
mCollection
(
h
));
}
decltype
(
auto
)
operator
()(
index_t
h
)
const
{
return
mFunc
(
mCollection
(
h
));
}
decltype
(
auto
)
operator
[](
handle_t
h
)
{
return
mFunc
(
mCollection
(
h
));
}
decltype
(
auto
)
operator
[](
index_t
h
)
{
return
mFunc
(
mCollection
(
h
));
}
decltype
(
auto
)
operator
()(
handle_t
h
)
{
return
mFunc
(
mCollection
(
h
));
}
decltype
(
auto
)
operator
()(
index_t
h
)
{
return
mFunc
(
mCollection
(
h
));
}
int
size
()
const
{
return
mCollection
.
size
();
}
template
<
class
F
>
auto
map
(
F
&&
f
)
const
{
auto
f2
=
[
ff
=
std
::
forward
<
F
>
(
f
)](
output_t
const
&
v
)
{
return
f
f
(
v
);
};
return
attribute_view
<
CollectionT
,
decltype
(
f
2
)
>
(
mCollection
,
std
::
move
(
f
2
));
auto
new_f
=
[
f0
=
mFunc
,
f1
=
std
::
forward
<
F
>
(
f
)](
auto
&&
v
)
->
decltype
(
auto
)
{
return
f
1
(
f0
(
v
)
)
;
};
return
attribute_view
<
CollectionT
,
decltype
(
new_
f
)
>
(
mCollection
,
std
::
move
(
new_
f
));
}
private
:
CollectionT
mCollection
;
CollectionT
&
mCollection
;
FuncT
mFunc
;
};
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment