mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 08:11:04 +01:00
Switch to trailing returns in toolchain and related code. (#4919)
Also makes the style guide explicitly comment on void, but this was the intent IIRC because it matches Carbon's `-> ()` (and "always" versus "except for void", which we definitely went back and forth on). Includes adjusting function pointers, which I definitely forget this syntax works sometimes. Excludes utils/tree_sitter/src/scanner.c because it claims to be C, but really we should probably fix that to be cpp.
This commit is contained in:
+6
-4
@@ -25,7 +25,7 @@ using ::testing::Pair;
|
||||
using ::testing::UnorderedElementsAreArray;
|
||||
|
||||
template <typename MapT, typename MatcherRangeT>
|
||||
void ExpectMapElementsAre(MapT&& m, MatcherRangeT element_matchers) {
|
||||
auto ExpectMapElementsAre(MapT&& m, MatcherRangeT element_matchers) -> void {
|
||||
// Now collect the elements into a container.
|
||||
using KeyT = typename std::remove_reference<MapT>::type::KeyT;
|
||||
using ValueT = typename std::remove_reference<MapT>::type::ValueT;
|
||||
@@ -41,14 +41,16 @@ void ExpectMapElementsAre(MapT&& m, MatcherRangeT element_matchers) {
|
||||
|
||||
// Allow directly using an initializer list.
|
||||
template <typename MapT, typename MatcherT>
|
||||
void ExpectMapElementsAre(MapT&& m,
|
||||
std::initializer_list<MatcherT> element_matchers) {
|
||||
auto ExpectMapElementsAre(MapT&& m,
|
||||
std::initializer_list<MatcherT> element_matchers)
|
||||
-> void {
|
||||
std::vector<MatcherT> element_matchers_storage = element_matchers;
|
||||
ExpectMapElementsAre(m, element_matchers_storage);
|
||||
}
|
||||
|
||||
template <typename ValueCB, typename RangeT, typename... RangeTs>
|
||||
auto MakeKeyValues(ValueCB value_cb, RangeT&& range, RangeTs&&... ranges) {
|
||||
auto MakeKeyValues(ValueCB value_cb, RangeT&& range, RangeTs&&... ranges)
|
||||
-> auto {
|
||||
using KeyT = typename RangeT::value_type;
|
||||
using ValueT = decltype(value_cb(std::declval<KeyT>()));
|
||||
std::vector<std::pair<KeyT, ValueT>> elements;
|
||||
|
||||
Reference in New Issue
Block a user