Skip to content

Commit

Permalink
Replace auto with explicit type
Browse files Browse the repository at this point in the history
It seems that the older c++ version was deducing auto as a
initializer_list rather than a size_t

Fixes #161
  • Loading branch information
Robin Miller committed Apr 12, 2018
1 parent 6d717b1 commit 1fa32e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
15 changes: 7 additions & 8 deletions examples/tools/attrs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ constexpr auto DEFAULT{MakeAttrs(PopulationSize(100), GenerationLength(100),
// Notice that this function has a different ordering than DEFAULT
void print(
const std::string& name,
const Attrs<PopulationSizeValue<size_t>, DefaultGenomeValue<std::string>,
GenerationLengthValue<size_t>>& args) {
const Attrs<PopulationSizeValue<int>, DefaultGenomeValue<std::string>,
GenerationLengthValue<int>>& args) {
std::cout << name << " = " << args << std::endl;
}

void printSubset(
const std::string& name,
const Attrs<typename PopulationSize::value_t<size_t>,
typename GenerationLength::value_t<size_t>>& args) {
void printSubset(const std::string& name,
const Attrs<typename PopulationSize::value_t<int>,
typename GenerationLength::value_t<int>>& args) {
std::cout << name << " = " << args << std::endl;
}

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

Attrs<typename PopulationSize::value_t<size_t>,
Attrs<typename PopulationSize::value_t<int>,
typename DefaultGenome::value_t<std::string>, // Notice that this will
// be auto-converted
typename GenerationLength::value_t<size_t>>
typename GenerationLength::value_t<int>>
user = DEFAULT;
// Set a single member
user.SetDefaultGenome("ASDEDFDFSA");
Expand Down
2 changes: 1 addition & 1 deletion source/meta/type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ namespace emp {

template <typename Needle, typename Haystack,
template <typename, typename> class... Cmp>
static constexpr auto variadic_index_of_v{
static constexpr size_t variadic_index_of_v{
variadic_index_of<Needle, Haystack, Cmp...>::value};

namespace __impl_variadics_type_traits {
Expand Down
2 changes: 1 addition & 1 deletion source/tools/attrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ namespace emp {
/// of attributes and returns a pack containing each of those attributes.
template <class... T>
constexpr Attrs<std::decay_t<T>...> MakeAttrs(T&&... props) {
return {std::forward<T>(props)...};
return Attrs<std::decay_t<T>...>(std::forward<T>(props)...);
};

namespace __impl_attrs_merge {
Expand Down

0 comments on commit 1fa32e3

Please sign in to comment.