@@ -250,10 +250,7 @@ using ord_result_t =
250250 decltype (std::declval<F>()(type::detail::pos_to_ordinal<I>{}));
251251
252252template <size_t ... I, typename F>
253- constexpr ord_result_t <F> find_by_ordinal_impl (
254- F&& f, std::index_sequence<I...>);
255- template <typename F>
256- constexpr bool find_by_ordinal_impl (F&&, std::index_sequence<>);
253+ ord_result_t <F> find_by_ordinal_impl (F&& f, std::index_sequence<I...>);
257254
258255struct GetValueOrNull {
259256 template <typename T>
@@ -337,15 +334,22 @@ constexpr void for_each_ordinal(F&& f) {
337334 std::forward<F>(f), std::make_integer_sequence<size_t , num_fields<T>>{});
338335}
339336
340- // / Calls the given function with with ordinal<1> to ordinal<N>, returning the
341- // / first truthy result produced.
342- // / Returns false when called on empty structs.
343- template <typename T, typename F>
344- constexpr decltype (auto ) find_by_ordinal(F&& f) {
337+ // / Calls the given function with with ordinal<1> to ordinal<N>, returing the
338+ // / first 'true' result produced.
339+ template <
340+ typename T,
341+ typename F,
342+ std::enable_if_t <num_fields<T> != 0 >* = nullptr >
343+ decltype (auto ) find_by_ordinal(F&& f) {
345344 return detail::find_by_ordinal_impl (
346345 std::forward<F>(f), std::make_integer_sequence<size_t , num_fields<T>>{});
347346}
348347
348+ template <typename T, typename F>
349+ std::enable_if_t <num_fields<T> == 0 , bool > find_by_ordinal (F&&) {
350+ return false ;
351+ }
352+
349353template <typename T, typename Id>
350354using get_field_id = type::field_id<
351355 get_ordinal<T, Id>::value == type::Ordinal()
@@ -473,8 +477,7 @@ constexpr void for_each_ordinal_impl(F&& f, std::index_sequence<I...>) {
473477}
474478
475479template <size_t ... I, typename F>
476- constexpr ord_result_t <F> find_by_ordinal_impl (
477- F&& f, std::index_sequence<I...>) {
480+ ord_result_t <F> find_by_ordinal_impl (F&& f, std::index_sequence<I...>) {
478481 auto result = ord_result_t <F>();
479482 // TODO(afuller): Use a short circuting c++17 folding expression.
480483 for_each_ordinal_impl (
@@ -487,10 +490,6 @@ constexpr ord_result_t<F> find_by_ordinal_impl(
487490 std::index_sequence<I...>{});
488491 return result;
489492}
490- template <typename F>
491- constexpr bool find_by_ordinal_impl (F&&, std::index_sequence<>) {
492- return false ;
493- }
494493
495494template <typename Id, typename T>
496495struct Get {
0 commit comments