Skip to content

Commit 4a12714

Browse files
committed
Avoid concrete return type to fix possible MSVC warning C4686.
1 parent 4868790 commit 4a12714

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

include/moose/range.h

+6
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ namespace moose
3232
Iterator begin;
3333
Iterator end;
3434
};
35+
36+
template <class Iterator>
37+
auto makeRange (Iterator const& begin, Iterator const& end) -> Range<Iterator>
38+
{
39+
return {begin, end};
40+
}
3541
}// end of namespace moose

include/moose/stl_serialization.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ namespace moose
5656

5757
static constexpr bool wantsToUnpack = true;
5858

59-
static auto toRange (Type& vector) -> Range <decltype (vector.begin ())>
59+
static auto toRange (Type& vector)
6060
{
61-
return {vector.begin (), vector.end ()};
61+
return makeRange (vector.begin (), vector.end ());
6262
}
6363

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

7878
static constexpr EntryType entryType = EntryType::Vector;
7979

80-
static auto toRange (Type& map) -> Range <decltype (map.begin ())>
80+
static auto toRange (Type& map)
8181
{
82-
return {map.begin (), map.end ()};
82+
return makeRange (map.begin (), map.end ());
8383
}
8484

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

9898
static constexpr EntryType entryType = EntryType::Vector;
9999

100-
static auto toRange (Type& set) -> Range <decltype (set.begin ())>
100+
static auto toRange (Type& set)
101101
{
102-
return {set.begin (), set.end ()};
102+
return makeRange (set.begin (), set.end ());
103103
}
104104

105105
static void pushBack (Type& set, ValueType const& value)

include/moose/type_traits.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ namespace moose
122122
struct DefaultRangeTraits
123123
{
124124
static constexpr EntryType entryType = EntryType::Range;
125-
static auto toRange (T& container) -> Range <decltype (container.begin ())>
125+
static auto toRange (T& container)
126126
{
127-
return {container.begin (), container.end ()};
127+
return makeRange (container.begin (), container.end ());
128128
}
129129
};
130130

0 commit comments

Comments
 (0)