-
- Downloads
[cling] Better SFINAE check to print collection values
In order to specialize cling's value-printing logic for collections
we perform some SFINAE checks. Among other things, the checks
assert that `++(obj.begin())` is well-formed. That compiles for
`std::vector` and other collections with "fat" iterators, but does
not compile for collections that use raw pointers as iterators:
```cpp
auto beg(std::vector<int> &v) {
return v.begin();
}
int *beg2(std::vector<int> &v) {
return &v[0];
}
int main() {
std::vector<int> v{1,2,3};
beg(v) += 1;
//beg2(v) += 1; // does not compile - beg2(v) is not an lvalue
return 0;
}
```
Requiring instead `std::begin(obj)` to be well-formed should be
backward compatible and it should allow collections that use raw
pointers as iterators to also be pretty-printed by cling.
Co-authored-by:
Axel Naumann <Axel.Naumann@cern.ch>
Loading
Please register or sign in to comment