logoalt Hacker News

rustystumptoday at 12:31 AM1 replyview on HN

Every language i am not deeply familiar with is disgusting.

But for real the ratings for me stem from how much arcane symbology i must newly memorize. I found rust to be up there but digestible. The thought of c++ makes me want to puke but not over the syntax.


Replies

kachapopopowtoday at 1:51 AM

  template<auto V>
  concept non_zero = (V != 0);

  template<typename T>
  concept arithmetic = std::is_arithmetic_v<T>;

  template<arithmetic T>
  requires non_zero<T{42}>
  struct complicated {
      template<auto... Values>
      using nested_alias = std::tuple<
          std::integral_constant<decltype(Values), Values>...,
          std::conditional_t<(Values > 0 && ...), T, std::nullptr_t>
      >;

      template<typename... Ts>
      static constexpr auto process() {
          return []<std::size_t... Is>(std::index_sequence<Is...>) {
              return nested_alias<(sizeof(Ts) + Is)...>{};
          }(std::make_index_sequence<sizeof...(Ts)>{});
      }
  };
I most definitely agree.