Skip to content

Commit b10648b

Browse files
author
Robin Miller
committed
Removes ambiguity from initializer lists as values
I think that the problem is caused by c++ assuming that the uniform constrctor syntax is acually an initializer list Fixes #161
1 parent 6d717b1 commit b10648b

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

examples/tools/attrs.cc

+7-8
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ constexpr auto DEFAULT{MakeAttrs(PopulationSize(100), GenerationLength(100),
1414
// Notice that this function has a different ordering than DEFAULT
1515
void print(
1616
const std::string& name,
17-
const Attrs<PopulationSizeValue<size_t>, DefaultGenomeValue<std::string>,
18-
GenerationLengthValue<size_t>>& args) {
17+
const Attrs<PopulationSizeValue<int>, DefaultGenomeValue<std::string>,
18+
GenerationLengthValue<int>>& args) {
1919
std::cout << name << " = " << args << std::endl;
2020
}
2121

22-
void printSubset(
23-
const std::string& name,
24-
const Attrs<typename PopulationSize::value_t<size_t>,
25-
typename GenerationLength::value_t<size_t>>& args) {
22+
void printSubset(const std::string& name,
23+
const Attrs<typename PopulationSize::value_t<int>,
24+
typename GenerationLength::value_t<int>>& args) {
2625
std::cout << name << " = " << args << std::endl;
2726
}
2827

@@ -43,10 +42,10 @@ int main() {
4342
"Using Universal Constructor: ",
4443
{PopulationSize(1), DefaultGenome("Hello World"), GenerationLength(50)});
4544

46-
Attrs<typename PopulationSize::value_t<size_t>,
45+
Attrs<typename PopulationSize::value_t<int>,
4746
typename DefaultGenome::value_t<std::string>, // Notice that this will
4847
// be auto-converted
49-
typename GenerationLength::value_t<size_t>>
48+
typename GenerationLength::value_t<int>>
5049
user = DEFAULT;
5150
// Set a single member
5251
user.SetDefaultGenome("ASDEDFDFSA");

source/tools/attrs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ namespace emp {
911911
/// of attributes and returns a pack containing each of those attributes.
912912
template <class... T>
913913
constexpr Attrs<std::decay_t<T>...> MakeAttrs(T&&... props) {
914-
return {std::forward<T>(props)...};
914+
return Attrs<std::decay_t<T>...>(std::forward<T>(props)...);
915915
};
916916

917917
namespace __impl_attrs_merge {

0 commit comments

Comments
 (0)