https://bugs.llvm.org/show_bug.cgi?id=32208

            Bug ID: 32208
           Summary: clang format misinterprets less-than-operator inside
                    template declaration with enable_if
           Product: clang
           Version: 4.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangb...@nondot.org
          Reporter: per.ola.nils...@gmail.com
                CC: djas...@google.com, kli...@google.com,
                    llvm-bugs@lists.llvm.org

clang-format seems to misinterpret less-than operator inside enable_if. First
manually formatted code, where enable_if aligns between the two functions:

$ cat for_each_tuple_indexed.h 
#pragma once
#include <tuple>
#include <utility>

template <std::size_t I = 0, typename FuncT, typename... Tp>
inline typename std::enable_if<I == sizeof...(Tp), void>::type
for_each_indexed(
    const std::tuple<Tp...> &,
    FuncT &&) { // recursion terminal case, I is equal to length of tuple
}

template <std::size_t I = 0, typename FuncT, typename... Tp>
inline typename std::enable_if<I < sizeof...(Tp), void>::type for_each_indexed(
    const std::tuple<Tp...> &t,
    FuncT &&f) {
  std::forward<FuncT>(f)(std::get<I>(t), I);
  for_each_indexed<I + 1, FuncT, Tp...>(t, std::forward<FuncT>(f));
}

====== 

$ clang-format-4.0 -style=llvm  for_each_tuple_indexed.h 
#pragma once
#include <tuple>
#include <utility>

template <std::size_t I = 0, typename FuncT, typename... Tp>
inline typename std::enable_if<I == sizeof...(Tp), void>::type
for_each_tuple_indexed(
    const std::tuple<Tp...> &,
    FuncT &&) { // recursion terminal case, I is equal to length of tuple
}

template <std::size_t I = 0, typename FuncT, typename... Tp>
    inline typename std::enable_if <
    I<sizeof...(Tp), void>::type
    for_each_tuple_indexed(const std::tuple<Tp...> &t, FuncT &&f) {
  std::forward<FuncT>(f)(std::get<I>(t), I);
  for_each_indexed<I + 1, FuncT, Tp...>(t, std::forward<FuncT>(f));
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to