You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Needs a check that will find creations of a tuple-like which was assigned from a returned value. The check will show warning to change it to use std::tie.
Also the check will provide fix-it in the case when it's possible to deduce names for future "tied" variables.
BEFORE:
iterator it;
bool succeed;
const auto results = mapping.try_emplace("hello!"); // WARNING AND FIX-IT
it = results.first;
succeed = results.second; // deduced 'it' and 'succeed'
AFTER:
iterator it;
bool succeed;
std::tie(it, succeed) = mapping.try_emplace("hello!"); // use 'it' and 'succeed'
The check will respect original order of default constructors, copy constructors, and assignment operators for a not built-in type and will not provide a fix-it that will broke the order - only warning will be emited:
const auto results = mapping.try_emplace("hello!"); // WARNING
const iterator& it = results.first; // only copy constructor being called
// but with `std::tie` we would call default constructor, copy constructor and then assignment operator
const bool succeed = results.second;
Another example with a built-in type:
const auto pos = get_position(); // WARNING AND FIX-IT
const float x = pos.first;
const float y = pos.second;
Keep in mind that the check will not provide fix-it in the case when it's impossible to deduce names - just a warning would be enough:
const auto results = mapping.try_emplace("hello!"); // WARNING
if (results.second) {
handle_inserted(results.first);
}
// no name deduced
In the case when it's impossible to use std::tie no warning must be provided:
const auto results = mapping.try_emplace("hello!");
handle_inserted(results);
The text was updated successfully, but these errors were encountered:
Needs a check that will find creations of a tuple-like which was assigned from a returned value. The check will show warning to change it to use `std::tie`.
Also the check will provide fix-it in the case when it's possible to deduce names for future "tied" variables.
BEFORE:
iterator it;
bool succeed;
const auto results = mapping.try_emplace("hello!"); // WARNING AND FIX-IT
it = results.first;
succeed = results.second; // deduced 'it' and 'succeed'
AFTER:
iterator it;
bool succeed;
std::tie(it, succeed) = mapping.try_emplace("hello!"); // use 'it' and 'succeed'
The check will respect original order of default constructors, copy constructors, and assignment operators for a not built-in type and will not provide a fix-it that will broke the order - only warning will be emited:
const auto results = mapping.try_emplace("hello!"); // WARNING
const iterator& it = results.first; // only copy constructor being called
// but with `std::tie` we would call default constructor, copy constructor and then assignment operator
const bool succeed = results.second;
Another example with a built-in type:
const auto pos = get_position(); // WARNING AND FIX-IT
const float x = pos.first;
const float y = pos.second;
Keep in mind that the check will not provide fix-it in the case when it's impossible to deduce names - just a warning would be enough:
const auto results = mapping.try_emplace("hello!"); // WARNING
if (results.second) {
handle_inserted(results.first);
}
// no name deduced
In the case when it's impossible to use std::tie no warning must be provided:
const auto results = mapping.try_emplace("hello!");
handle_inserted(results);
Needs a check that will find creations of a tuple-like which was assigned from a returned value. The check will show warning to change it to use
std::tie
.Also the check will provide fix-it in the case when it's possible to deduce names for future "tied" variables.
BEFORE:
AFTER:
The check will respect original order of default constructors, copy constructors, and assignment operators for a not built-in type and will not provide a fix-it that will broke the order - only warning will be emited:
Another example with a built-in type:
Keep in mind that the check will not provide fix-it in the case when it's impossible to deduce names - just a warning would be enough:
In the case when it's impossible to use
std::tie
no warning must be provided:The text was updated successfully, but these errors were encountered: