no viable conversion from returned value of type 'std::bitset<3>' to function return type 'int'

63 views Asked by At

bitmark.hpp

class BitMark {
 public:
  using mark_t = std::bitset<2>;
  constexpr static mark_t A{0b00};
  static constexpr std::optional<mark_t> FromAsciiIdx(int c) {
    switch (c) {
      case 1:
        return A;
      default:
        return {};
    }
  }
};

run /usr/bin/clang-tidy bitmark.hpp --checks='cppcoreguidelines-*'

return error: no viable conversion from returned value of type 'const BitMark::mark_t' (aka 'const bitset<2>') to function return type 'int' [clang-diagnostic-error] return A;

why? Is there an implicit conversion happening here? But I changed the return value to std::bitset<2>{A} and it still threw this error.my clang-tidy version is 15.0.7.

1

There are 1 answers

0
Elliot On BEST ANSWER

Pay attention to compile_commands.json in the root directory and ensure that it is the latest link. clang-tidy will read this file. As of the reply, I still have not found a way to correctly set the build-path in vscode.After I find it, I will reply to the setting method of vscode here.