Re: Issue 927 in include-what-you-use: False positive <type_traits> for enable_if_t and remove_reference<>::type

0 views
Skip to first unread message

notifi...@include-what-you-use.org

unread,
Jul 31, 2021, 6:11:31 AM7/31/21
to include-wh...@googlegroups.com
Comment #0 on issue 927 by kimgr: False positive <type_traits> for enable_if_t and remove_reference<>::type
https://github.com/include-what-you-use/include-what-you-use/issues/927

Looks like `operator bool` triggers something in the first example:

* `std::enable_if_t<true, B>` resolves to `B`
* A call through `B::operator bool` is necessary to convert `B` to `bool` for return from `method`
* That call happens through `std::enable_if_t` even if it just happens to be a typedef/using decl for `B`

I think in a smaller, related example this would make more sense:
```
// a.h
#include <string>
typedef std::string MyString;

// t.cc
#include "a.h"
int f() {
return MyString().size();
}
```

In the above, it makes sense that the mention of `MyString` and call to `size` refer to `a.h`.

The complication with `enable_if` is that it's supposed to be transparent, so referring to `<type_traits>` looks off. I think `remove_reference` is similar -- it's a typedef that doesn't really want to introduce a new name, just massage types.

Not sure how to detect that more generally...

Reply all
Reply to author
Forward
0 new messages