1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Remove inclusion of algorithm almost everywhere

This commit is contained in:
Matias Fontanini
2017-04-30 18:51:55 -07:00
parent 58a4d336b9
commit a07b3e8a3a
19 changed files with 87 additions and 110 deletions

View File

@@ -410,7 +410,7 @@ public:
* \return The stored options.
*/
const options_type& options() const {
return ip_options_;
return options_;
}
/* Setters */
@@ -525,7 +525,7 @@ public:
*/
void add_option(option &&opt) {
internal_add_option(opt);
ip_options_.push_back(std::move(opt));
options_.push_back(std::move(opt));
}
/**
@@ -538,8 +538,8 @@ public:
*/
template<typename... Args>
void add_option(Args&&... args) {
ip_options_.emplace_back(std::forward<Args>(args)...);
internal_add_option(ip_options_.back());
options_.emplace_back(std::forward<Args>(args)...);
internal_add_option(options_.back());
}
#endif
@@ -770,7 +770,7 @@ private:
ip_header header_;
uint16_t options_size_, padded_options_size_;
options_type ip_options_;
options_type options_;
};
} // Tins

View File

@@ -537,22 +537,36 @@ private:
};
namespace Internals {
/*
* \cond
*/
template <typename Option>
struct option_type_equality_comparator {
option_type_equality_comparator(typename Option::option_type type) : type(type) { }
/*
* \cond
*/
bool operator()(const Option& opt) const {
return opt.option() == type;
template <typename Option, typename Container>
typename Container::iterator find_option(Container& cont, typename Option::option_type type) {
typename Container::iterator iter;
for (iter = cont.begin(); iter != cont.end(); ++iter) {
if (iter->option() == type) {
break;
}
}
return iter;
}
typename Option::option_type type;
};
/*
* \endcond
*/
template <typename Option, typename Container>
typename Container::const_iterator find_option_const(const Container& cont,
typename Option::option_type type) {
typename Container::const_iterator iter;
for (iter = cont.begin(); iter != cont.end(); ++iter) {
if (iter->option() == type) {
break;
}
}
return iter;
}
/*
* \endcond
*/
} // Internals
} // namespace Tins