abseil / abseil/abseil-cpp

StrSplit return as std::set/absl::flat_hash_set triggers warning

Abierto
#1,233 0 comentarios 0 reacciones 0 asignados Ver en GitHub
question
Lenguaje dominante
C++
Estrellas
18.1k
Forks
3.2k
Merge medio
20 h 36 min
PR fusionados (30 d)
1

Descripción

I'm currently using Abseil-app from the master branch. My code:
```c++
std::set controllers = absl::StrSplit(*content, ' '); // content: absl::StatusOr
```
Would trigger:
```shell
In file included from /home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/strings/str_split.h:48,
from /home/parallels/weiran-dev/rouster/src/main.cpp:11:
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h: In instantiation of ‘absl::strings_internal::SplitIterator& absl::strings_internal::SplitIterator::operator++() [with Splitter = absl::strings_internal::Splitter >]’:
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h:321:7: required from ‘Container absl::strings_internal::Splitter::ConvertToContainer::operator()(const absl::strings_internal::Splitter&) const [with Container = std::set >; ValueType = std::__cxx11::basic_string; bool is_map = false; Delimiter = absl::ByChar; Predicate = absl::AllowEmpty; StringType = std::basic_string_view]’
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h:288:65: required from ‘absl::strings_internal::Splitter::operator Container() const [with Container = std::set >; = void; Delimiter = absl::ByChar; Predicate = absl::AllowEmpty; StringType = std::basic_string_view]’
/home/parallels/weiran-dev/rouster/src/main.cpp:54:71: required from here
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h:135:42: warning: conversion to ‘std::basic_string_view::size_type’ {aka ‘long unsigned int’} from ‘long int’ may change the sign of the result [-Wsign-conversion]
135 | curr_ = text.substr(pos_, d.data() - (text.data() + pos_));
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
```
And `absl::flat_hash_set` will trigger additional warnings (besides the above warning):
```shell
In file included from /home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h:40,
from /home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/container/internal/inlined_vector.h:30,
from /home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/container/inlined_vector.h:53,
from /home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/status/status.h:57,
from /home/parallels/weiran-dev/rouster/src/linux/sys.h:1,
from /home/parallels/weiran-dev/rouster/src/container.hpp:12,
from /home/parallels/weiran-dev/rouster/src/main.cpp:6:
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/utility/utility.h: In instantiation of ‘T absl::exchange(T&, U&&) [with T = long unsigned int; U = int]’:
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h:1275:29: required from ‘absl::container_internal::raw_hash_set::raw_hash_set(absl::container_internal::raw_hash_set&&) [with Policy = absl::container_internal::FlatHashSetPolicy >; Hash = absl::container_internal::StringHash; Eq = absl::container_internal::StringEq; Alloc = std::allocator >]’
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/container/flat_hash_set.h:105:7: required from ‘Container absl::strings_internal::Splitter::ConvertToContainer::operator()(const absl::strings_internal::Splitter&) const [with Container = absl::flat_hash_set >; ValueType = std::basic_string_view; bool is_map = false; Delimiter = absl::ByChar; Predicate = absl::AllowEmpty; StringType = std::basic_string_view]’
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h:288:65: required from ‘absl::strings_internal::Splitter::operator Container() const [with Container = absl::flat_hash_set >; = void; Delimiter = absl::ByChar; Predicate = absl::AllowEmpty; StringType = std::basic_string_view]’
/home/parallels/weiran-dev/rouster/src/main.cpp:54:87: required from here
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/utility/utility.h:316:7: warning: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
316 | obj = absl::forward(new_value);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

Seems like there exist some implicit conversions. Though these are not errors, can we have a fix for them?

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.