Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
dfad0b1b
Commit
dfad0b1b
authored
3 years ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Rework vector<bool> conversion to string to satisfy libstdc++9
This is quite a stupid hack
parent
fb973b01
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!144
Add R^dxd and R^d expressions in pugs' language (with d=1,2 or 3)
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/language/node_processor/AffectationProcessor.hpp
+43
-49
43 additions, 49 deletions
src/language/node_processor/AffectationProcessor.hpp
with
43 additions
and
49 deletions
src/language/node_processor/AffectationProcessor.hpp
+
43
−
49
View file @
dfad0b1b
...
@@ -82,6 +82,15 @@ class AffectationExecutor final : public IAffectationExecutor
...
@@ -82,6 +82,15 @@ class AffectationExecutor final : public IAffectationExecutor
return
true
;
return
true
;
}()};
}()};
template
<
typename
T
>
std
::
string
_stringify
(
const
T
&
value
)
{
std
::
ostringstream
os
;
os
<<
std
::
boolalpha
<<
value
;
return
os
.
str
();
}
public
:
public
:
AffectationExecutor
(
ASTNode
&
node
,
ValueT
&
lhs
)
:
m_lhs
(
lhs
)
AffectationExecutor
(
ASTNode
&
node
,
ValueT
&
lhs
)
:
m_lhs
(
lhs
)
{
{
...
@@ -96,29 +105,19 @@ class AffectationExecutor final : public IAffectationExecutor
...
@@ -96,29 +105,19 @@ class AffectationExecutor final : public IAffectationExecutor
affect
(
ExecutionPolicy
&
,
DataVariant
&&
rhs
)
affect
(
ExecutionPolicy
&
,
DataVariant
&&
rhs
)
{
{
if
constexpr
(
m_is_defined
)
{
if
constexpr
(
m_is_defined
)
{
auto
stringify
=
[](
auto
&&
value
)
{
std
::
ostringstream
os
;
if
constexpr
(
std
::
is_same_v
<
std
::
decay_t
<
decltype
(
value
)
>
,
bool
>
)
{
os
<<
std
::
boolalpha
<<
value
;
}
else
{
os
<<
value
;
}
return
os
.
str
();
};
if
constexpr
(
not
std
::
is_same_v
<
DataT
,
ZeroType
>
)
{
if
constexpr
(
not
std
::
is_same_v
<
DataT
,
ZeroType
>
)
{
if
constexpr
(
std
::
is_same_v
<
ValueT
,
std
::
string
>
)
{
if
constexpr
(
std
::
is_same_v
<
ValueT
,
std
::
string
>
)
{
if
constexpr
(
std
::
is_same_v
<
OperatorT
,
language
::
eq_op
>
)
{
if
constexpr
(
std
::
is_same_v
<
OperatorT
,
language
::
eq_op
>
)
{
if
constexpr
(
std
::
is_same_v
<
std
::
string
,
DataT
>
)
{
if
constexpr
(
std
::
is_same_v
<
std
::
string
,
DataT
>
)
{
m_lhs
=
std
::
get
<
DataT
>
(
rhs
);
m_lhs
=
std
::
get
<
DataT
>
(
rhs
);
}
else
{
}
else
{
m_lhs
=
std
::
move
(
stringify
(
std
::
get
<
DataT
>
(
rhs
)));
m_lhs
=
std
::
move
(
_
stringify
(
std
::
get
<
DataT
>
(
rhs
)));
}
}
}
else
{
}
else
{
if
constexpr
(
std
::
is_same_v
<
std
::
string
,
DataT
>
)
{
if
constexpr
(
std
::
is_same_v
<
std
::
string
,
DataT
>
)
{
m_lhs
+=
std
::
get
<
std
::
string
>
(
rhs
);
m_lhs
+=
std
::
get
<
std
::
string
>
(
rhs
);
}
else
{
}
else
{
m_lhs
+=
std
::
move
(
stringify
(
std
::
get
<
DataT
>
(
rhs
)));
m_lhs
+=
std
::
move
(
_
stringify
(
std
::
get
<
DataT
>
(
rhs
)));
}
}
}
}
}
else
{
}
else
{
...
@@ -184,9 +183,16 @@ class AffectationExecutor final : public IAffectationExecutor
...
@@ -184,9 +183,16 @@ class AffectationExecutor final : public IAffectationExecutor
std
::
visit
(
std
::
visit
(
[
&
](
auto
&&
v
)
{
[
&
](
auto
&&
v
)
{
if
constexpr
(
is_std_vector_v
<
std
::
decay_t
<
decltype
(
v
)
>>
)
{
using
V_T
=
std
::
decay_t
<
decltype
(
v
)
>
;
if
constexpr
(
is_std_vector_v
<
V_T
>
)
{
for
(
size_t
i
=
0
;
i
<
v
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
v
.
size
();
++
i
)
{
m_lhs
[
i
]
=
std
::
move
(
stringify
(
v
[
i
]));
if
constexpr
(
std
::
is_same_v
<
typename
V_T
::
value_type
,
bool
>
)
{
// Ugly workaround to allow compilation with libstdc++-9
bool
v_i
=
v
[
i
];
m_lhs
[
i
]
=
std
::
move
(
_stringify
(
v_i
));
}
else
{
m_lhs
[
i
]
=
std
::
move
(
_stringify
(
v
[
i
]));
}
}
}
}
else
{
}
else
{
// LCOV_EXCL_START
// LCOV_EXCL_START
...
@@ -270,7 +276,7 @@ class AffectationExecutor final : public IAffectationExecutor
...
@@ -270,7 +276,7 @@ class AffectationExecutor final : public IAffectationExecutor
std
::
is_convertible_v
<
T
,
ValueContentT
>
)
{
std
::
is_convertible_v
<
T
,
ValueContentT
>
)
{
tuple_value
[
i
]
=
static_cast
<
ValueContentT
>
(
child_value
);
tuple_value
[
i
]
=
static_cast
<
ValueContentT
>
(
child_value
);
}
else
if
constexpr
(
std
::
is_same_v
<
std
::
string
,
ValueContentT
>
)
{
}
else
if
constexpr
(
std
::
is_same_v
<
std
::
string
,
ValueContentT
>
)
{
tuple_value
[
i
]
=
std
::
move
(
stringify
(
child_value
));
tuple_value
[
i
]
=
std
::
move
(
_
stringify
(
child_value
));
}
else
if
constexpr
(
is_tiny_vector_v
<
ValueContentT
>
)
{
}
else
if
constexpr
(
is_tiny_vector_v
<
ValueContentT
>
)
{
if
constexpr
(
std
::
is_arithmetic_v
<
T
>
)
{
if
constexpr
(
std
::
is_arithmetic_v
<
T
>
)
{
if
constexpr
(
std
::
is_same_v
<
ValueContentT
,
TinyVector
<
1
>>
)
{
if
constexpr
(
std
::
is_same_v
<
ValueContentT
,
TinyVector
<
1
>>
)
{
...
@@ -320,7 +326,7 @@ class AffectationExecutor final : public IAffectationExecutor
...
@@ -320,7 +326,7 @@ class AffectationExecutor final : public IAffectationExecutor
std
::
is_convertible_v
<
T
,
ValueContentT
>
)
{
std
::
is_convertible_v
<
T
,
ValueContentT
>
)
{
tuple_value
[
0
]
=
static_cast
<
ValueContentT
>
(
child_value
);
tuple_value
[
0
]
=
static_cast
<
ValueContentT
>
(
child_value
);
}
else
if
constexpr
(
std
::
is_same_v
<
std
::
string
,
ValueContentT
>
)
{
}
else
if
constexpr
(
std
::
is_same_v
<
std
::
string
,
ValueContentT
>
)
{
tuple_value
[
0
]
=
std
::
move
(
stringify
(
child_value
));
tuple_value
[
0
]
=
std
::
move
(
_
stringify
(
child_value
));
}
else
if
constexpr
(
is_tiny_vector_v
<
ValueContentT
>
)
{
}
else
if
constexpr
(
is_tiny_vector_v
<
ValueContentT
>
)
{
if
constexpr
(
std
::
is_arithmetic_v
<
T
>
)
{
if
constexpr
(
std
::
is_arithmetic_v
<
T
>
)
{
if
constexpr
(
std
::
is_same_v
<
ValueContentT
,
TinyVector
<
1
>>
)
{
if
constexpr
(
std
::
is_same_v
<
ValueContentT
,
TinyVector
<
1
>>
)
{
...
@@ -443,20 +449,19 @@ class AffectationToTupleProcessor final : public AffectationToDataVariantProcess
...
@@ -443,20 +449,19 @@ class AffectationToTupleProcessor final : public AffectationToDataVariantProcess
private:
private:
ASTNode
&
m_rhs_node
;
ASTNode
&
m_rhs_node
;
public:
template
<
typename
T
>
DataVariant
std
::
string
execute
(
ExecutionPolicy
&
exec_policy
)
_stringify
(
const
T
&
value
)
{
{
auto
stringify
=
[](
auto
&&
value
)
{
std
::
ostringstream
os
;
std
::
ostringstream
os
;
if
constexpr
(
std
::
is_same_v
<
std
::
decay_t
<
decltype
(
value
)
>
,
bool
>
)
{
os
<<
std
::
boolalpha
<<
value
;
os
<<
std
::
boolalpha
<<
value
;
}
else
{
os
<<
value
;
}
return
os
.
str
();
return
os
.
str
();
}
;
}
public
:
DataVariant
execute
(
ExecutionPolicy
&
exec_policy
)
{
DataVariant
value
=
m_rhs_node
.
execute
(
exec_policy
);
DataVariant
value
=
m_rhs_node
.
execute
(
exec_policy
);
std
::
visit
(
std
::
visit
(
...
@@ -467,7 +472,7 @@ class AffectationToTupleProcessor final : public AffectationToDataVariantProcess
...
@@ -467,7 +472,7 @@ class AffectationToTupleProcessor final : public AffectationToDataVariantProcess
}
else
if
constexpr
(
std
::
is_arithmetic_v
<
ValueT
>
and
std
::
is_convertible_v
<
T
,
ValueT
>
)
{
}
else
if
constexpr
(
std
::
is_arithmetic_v
<
ValueT
>
and
std
::
is_convertible_v
<
T
,
ValueT
>
)
{
*
m_lhs
=
std
::
vector
{
std
::
move
(
static_cast
<
ValueT
>
(
v
))};
*
m_lhs
=
std
::
vector
{
std
::
move
(
static_cast
<
ValueT
>
(
v
))};
}
else
if
constexpr
(
std
::
is_same_v
<
std
::
string
,
ValueT
>
)
{
}
else
if
constexpr
(
std
::
is_same_v
<
std
::
string
,
ValueT
>
)
{
*
m_lhs
=
std
::
vector
{
std
::
move
(
stringify
(
v
))};
*
m_lhs
=
std
::
vector
{
std
::
move
(
_
stringify
(
v
))};
}
else
if
constexpr
(
is_tiny_vector_v
<
ValueT
>
or
is_tiny_matrix_v
<
ValueT
>
)
{
}
else
if
constexpr
(
is_tiny_vector_v
<
ValueT
>
or
is_tiny_matrix_v
<
ValueT
>
)
{
if
constexpr
(
std
::
is_same_v
<
ValueT
,
TinyVector
<
1
>>
and
std
::
is_arithmetic_v
<
T
>
)
{
if
constexpr
(
std
::
is_same_v
<
ValueT
,
TinyVector
<
1
>>
and
std
::
is_arithmetic_v
<
T
>
)
{
*
m_lhs
=
std
::
vector
<
TinyVector
<
1
>>
{
TinyVector
<
1
>
{
static_cast
<
double
>
(
v
)}};
*
m_lhs
=
std
::
vector
<
TinyVector
<
1
>>
{
TinyVector
<
1
>
{
static_cast
<
double
>
(
v
)}};
...
@@ -503,19 +508,18 @@ class AffectationToTupleFromListProcessor final : public AffectationToDataVarian
...
@@ -503,19 +508,18 @@ class AffectationToTupleFromListProcessor final : public AffectationToDataVarian
private:
private:
ASTNode
&
m_rhs_node
;
ASTNode
&
m_rhs_node
;
void
template
<
typename
T
>
_copyAggregateDataVariant
(
const
AggregateDataVariant
&
children_values
)
std
::
string
_stringify
(
const
T
&
value
)
{
{
auto
stringify
=
[](
auto
&&
value
)
{
std
::
ostringstream
os
;
std
::
ostringstream
os
;
if
constexpr
(
std
::
is_same_v
<
std
::
decay_t
<
decltype
(
value
)
>
,
bool
>
)
{
os
<<
std
::
boolalpha
<<
value
;
os
<<
std
::
boolalpha
<<
value
;
}
else
{
os
<<
value
;
}
return
os
.
str
();
return
os
.
str
();
}
;
}
void
_copyAggregateDataVariant
(
const
AggregateDataVariant
&
children_values
)
{
std
::
vector
<
ValueT
>
tuple_value
(
children_values
.
size
());
std
::
vector
<
ValueT
>
tuple_value
(
children_values
.
size
());
for
(
size_t
i
=
0
;
i
<
children_values
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
children_values
.
size
();
++
i
)
{
std
::
visit
(
std
::
visit
(
...
@@ -526,7 +530,7 @@ class AffectationToTupleFromListProcessor final : public AffectationToDataVarian
...
@@ -526,7 +530,7 @@ class AffectationToTupleFromListProcessor final : public AffectationToDataVarian
}
else
if
constexpr
(
std
::
is_arithmetic_v
<
ValueT
>
and
std
::
is_convertible_v
<
T
,
ValueT
>
)
{
}
else
if
constexpr
(
std
::
is_arithmetic_v
<
ValueT
>
and
std
::
is_convertible_v
<
T
,
ValueT
>
)
{
tuple_value
[
i
]
=
static_cast
<
ValueT
>
(
child_value
);
tuple_value
[
i
]
=
static_cast
<
ValueT
>
(
child_value
);
}
else
if
constexpr
(
std
::
is_same_v
<
std
::
string
,
ValueT
>
)
{
}
else
if
constexpr
(
std
::
is_same_v
<
std
::
string
,
ValueT
>
)
{
tuple_value
[
i
]
=
std
::
move
(
stringify
(
child_value
));
tuple_value
[
i
]
=
std
::
move
(
_
stringify
(
child_value
));
}
else
if
constexpr
(
is_tiny_vector_v
<
ValueT
>
)
{
}
else
if
constexpr
(
is_tiny_vector_v
<
ValueT
>
)
{
if
constexpr
(
std
::
is_arithmetic_v
<
T
>
)
{
if
constexpr
(
std
::
is_arithmetic_v
<
T
>
)
{
if
constexpr
(
std
::
is_same_v
<
ValueT
,
TinyVector
<
1
>>
)
{
if
constexpr
(
std
::
is_same_v
<
ValueT
,
TinyVector
<
1
>>
)
{
...
@@ -573,16 +577,6 @@ class AffectationToTupleFromListProcessor final : public AffectationToDataVarian
...
@@ -573,16 +577,6 @@ class AffectationToTupleFromListProcessor final : public AffectationToDataVarian
void
void
_copyVector
(
const
std
::
vector
<
DataType
>&
values
)
_copyVector
(
const
std
::
vector
<
DataType
>&
values
)
{
{
auto
stringify
=
[](
auto
&&
value
)
{
std
::
ostringstream
os
;
if
constexpr
(
std
::
is_same_v
<
std
::
decay_t
<
decltype
(
value
)
>
,
bool
>
)
{
os
<<
std
::
boolalpha
<<
value
;
}
else
{
os
<<
value
;
}
return
os
.
str
();
};
std
::
vector
<
ValueT
>
v
(
values
.
size
());
std
::
vector
<
ValueT
>
v
(
values
.
size
());
if
constexpr
(
std
::
is_same_v
<
ValueT
,
DataType
>
)
{
if
constexpr
(
std
::
is_same_v
<
ValueT
,
DataType
>
)
{
for
(
size_t
i
=
0
;
i
<
values
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
values
.
size
();
++
i
)
{
...
@@ -594,7 +588,7 @@ class AffectationToTupleFromListProcessor final : public AffectationToDataVarian
...
@@ -594,7 +588,7 @@ class AffectationToTupleFromListProcessor final : public AffectationToDataVarian
}
}
}
else
if
constexpr
(
std
::
is_same_v
<
ValueT
,
std
::
string
>
)
{
}
else
if
constexpr
(
std
::
is_same_v
<
ValueT
,
std
::
string
>
)
{
for
(
size_t
i
=
0
;
i
<
values
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
values
.
size
();
++
i
)
{
v
[
i
]
=
std
::
move
(
stringify
(
values
[
i
]));
v
[
i
]
=
std
::
move
(
_
stringify
(
values
[
i
]));
}
}
}
else
{
}
else
{
// LCOV_EXCL_START
// LCOV_EXCL_START
...
...
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