Skip to content

Commit

Permalink
Avoid concrete return type to fix possible MSVC warning C4686.
Browse files Browse the repository at this point in the history
  • Loading branch information
sreiter committed Sep 13, 2024
1 parent 4868790 commit 4a12714
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 6 additions & 0 deletions include/moose/range.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@ namespace moose
Iterator begin;
Iterator end;
};

template <class Iterator>
auto makeRange (Iterator const& begin, Iterator const& end) -> Range<Iterator>
{
return {begin, end};
}
}// end of namespace moose
12 changes: 6 additions & 6 deletions include/moose/stl_serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ namespace moose

static constexpr bool wantsToUnpack = true;

static auto toRange (Type& vector) -> Range <decltype (vector.begin ())>
static auto toRange (Type& vector)
{
return {vector.begin (), vector.end ()};
return makeRange (vector.begin (), vector.end ());
}

static void pushBack (Type& vector, ValueType const& value)
Expand All @@ -77,9 +77,9 @@ namespace moose

static constexpr EntryType entryType = EntryType::Vector;

static auto toRange (Type& map) -> Range <decltype (map.begin ())>
static auto toRange (Type& map)
{
return {map.begin (), map.end ()};
return makeRange (map.begin (), map.end ());
}

static void pushBack (Type& map, ValueType const& value)
Expand All @@ -97,9 +97,9 @@ namespace moose

static constexpr EntryType entryType = EntryType::Vector;

static auto toRange (Type& set) -> Range <decltype (set.begin ())>
static auto toRange (Type& set)
{
return {set.begin (), set.end ()};
return makeRange (set.begin (), set.end ());
}

static void pushBack (Type& set, ValueType const& value)
Expand Down
4 changes: 2 additions & 2 deletions include/moose/type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ namespace moose
struct DefaultRangeTraits
{
static constexpr EntryType entryType = EntryType::Range;
static auto toRange (T& container) -> Range <decltype (container.begin ())>
static auto toRange (T& container)
{
return {container.begin (), container.end ()};
return makeRange (container.begin (), container.end ());
}
};

Expand Down

0 comments on commit 4a12714

Please sign in to comment.