Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aidge_core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eclipse Projects
aidge
aidge_core
Commits
a4acfca1
Commit
a4acfca1
authored
1 year ago
by
Olivier BICHLER
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bug #8
parent
ab7187c2
No related branches found
No related tags found
1 merge request
!16
Unified interface for attributes
Pipeline
#32290
failed
1 year ago
Stage: static_analysis
Stage: build
Stage: test
Stage: coverage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/aidge/utils/StaticAttributes.hpp
+13
-14
13 additions, 14 deletions
include/aidge/utils/StaticAttributes.hpp
with
13 additions
and
14 deletions
include/aidge/utils/StaticAttributes.hpp
+
13
−
14
View file @
a4acfca1
...
...
@@ -95,11 +95,11 @@ public:
assert
(
false
&&
"attribute not found"
);
}
template
<
typename
R
,
std
::
size_t
SIZE
=
std
::
tuple_size
<
std
::
tuple
<
T
...>
>::
value
-
1
>
template
<
typename
R
,
std
::
size_t
SIZE
=
std
::
tuple_size
<
std
::
tuple
<
T
...>
>::
value
>
constexpr
typename
std
::
enable_if
<
(
SIZE
>
0
),
R
&>::
type
getAttr
(
std
::
size_t
i
)
{
if
(
i
==
SIZE
)
{
if
(
std
::
is_same
<
R
,
typename
std
::
tuple_element
<
SIZE
,
std
::
tuple
<
T
...
>>::
type
>::
value
)
{
return
reinterpret_cast
<
R
&>
(
std
::
get
<
SIZE
>
(
mAttrs
));
if
(
i
==
SIZE
-
1
)
{
if
(
std
::
is_same
<
R
,
typename
std
::
tuple_element
<
SIZE
-
1
,
std
::
tuple
<
T
...
>>::
type
>::
value
)
{
return
reinterpret_cast
<
R
&>
(
std
::
get
<
SIZE
-
1
>
(
mAttrs
));
}
else
{
assert
(
false
&&
"wrong attribute type"
);
...
...
@@ -110,25 +110,24 @@ public:
}
}
template
<
typename
R
,
std
::
size_t
SIZE
=
std
::
tuple_size
<
std
::
tuple
<
T
...>
>::
value
-
1
>
[[
noreturn
]]
constexpr
typename
std
::
enable_if
<
(
SIZE
<
=
0
),
R
&>::
type
getAttr
(
std
::
size_t
/*i*/
)
{
template
<
typename
R
,
std
::
size_t
SIZE
=
std
::
tuple_size
<
std
::
tuple
<
T
...>
>::
value
>
[[
noreturn
]]
constexpr
typename
std
::
enable_if
<
(
SIZE
=
=
0
),
R
&>::
type
getAttr
(
std
::
size_t
/*i*/
)
{
assert
(
false
&&
"attribute not found"
);
}
template
<
std
::
size_t
SIZE
=
std
::
tuple_size
<
std
::
tuple
<
T
...>
>::
value
-
1
>
constexpr
typename
std
::
enable_if
<
(
SIZE
>
0
),
std
::
string
>::
type
getAttrType
(
std
::
size_t
i
)
const
{
if
(
i
==
SIZE
)
{
return
typeid
(
typename
std
::
tuple_element
<
SIZE
,
std
::
tuple
<
T
...
>>::
type
)
.
name
()
;
template
<
std
::
size_t
SIZE
=
std
::
tuple_size
<
std
::
tuple
<
T
...>
>::
value
>
constexpr
typename
std
::
enable_if
<
(
SIZE
>
0
),
const
std
::
type_info
&
>::
type
getAttrType
(
std
::
size_t
i
)
const
{
if
(
i
==
SIZE
-
1
)
{
return
typeid
(
typename
std
::
tuple_element
<
SIZE
-
1
,
std
::
tuple
<
T
...
>>::
type
);
}
else
{
return
getAttrType
<
SIZE
-
1
>
(
i
);
}
}
template
<
std
::
size_t
SIZE
=
std
::
tuple_size
<
std
::
tuple
<
T
...>
>::
value
-
1
>
constexpr
typename
std
::
enable_if
<
(
SIZE
<
=
0
),
std
::
string
>::
type
getAttrType
(
std
::
size_t
/*i*/
)
const
{
template
<
std
::
size_t
SIZE
=
std
::
tuple_size
<
std
::
tuple
<
T
...>
>::
value
>
[[
noreturn
]]
constexpr
typename
std
::
enable_if
<
(
SIZE
=
=
0
),
const
std
::
type_info
&
>::
type
getAttrType
(
std
::
size_t
/*i*/
)
const
{
assert
(
false
&&
"attribute not found"
);
return
std
::
string
();
// useless, but makes MSVC happy
}
constexpr
const
std
::
tuple
<
T
...
>&
getStaticAttributes
()
const
{
...
...
@@ -153,7 +152,7 @@ public:
constexpr
std
::
string
getAttrType
(
const
std
::
string
&
name
)
const
override
final
{
for
(
std
::
size_t
i
=
0
;
i
<
size
(
EnumStrings
<
ATTRS_ENUM
>::
data
);
++
i
)
{
if
(
name
==
EnumStrings
<
ATTRS_ENUM
>::
data
[
i
])
{
return
getAttrType
(
i
);
return
getAttrType
(
i
)
.
name
()
;
}
}
...
...
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