From a92bb98810bcc9b09679428cc277960e41a5965f Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Wed, 7 Dec 2022 19:18:48 +0200 Subject: [PATCH] Remove inlines from things in binary_find --- include/rstl/algorithm.hpp | 8 ++++---- include/rstl/functional.hpp | 5 ++++- include/rstl/iterator.hpp | 4 ++-- include/rstl/pointer_iterator.hpp | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/rstl/algorithm.hpp b/include/rstl/algorithm.hpp index 0efc3bb9..d0f2c255 100644 --- a/include/rstl/algorithm.hpp +++ b/include/rstl/algorithm.hpp @@ -115,7 +115,7 @@ It lower_bound(It start, It end, const T& value, Cmp cmp) { } template < typename It, typename T, typename Cmp > -inline It binary_find(It start, It end, const T& value, Cmp cmp) { +It binary_find(It start, It end, const T& value, Cmp cmp) { It lower = lower_bound(start, end, value, cmp); bool found = false; if (lower != end && !cmp(value, *lower)) { @@ -158,13 +158,13 @@ inline pair_sorter_finder< T::value_type, less< select1st< typename T::value_typ } template < typename K, typename V, typename Cmp > -inline bool pair_sorter_finder< pair< K, V >, Cmp >::operator()(const K& a, +bool pair_sorter_finder< pair< K, V >, Cmp >::operator()(const K& a, const pair< K, V >& b) const { return cmp(a, b.first); } template < typename K, typename V, typename Cmp > -inline bool pair_sorter_finder< pair< K, V >, Cmp >::operator()(const pair< K, V >& a, +bool pair_sorter_finder< pair< K, V >, Cmp >::operator()(const pair< K, V >& a, const K& b) const { return cmp(a.first, b); } @@ -175,7 +175,7 @@ find_by_key(const T& container, const typename select1st< typename T::value_type >::value_type& key); template < typename T > -typename T::const_iterator inline find_by_key( +typename T::const_iterator find_by_key( const T& container, const typename select1st< typename T::value_type >::value_type& key) { return binary_find(container.begin(), container.end(), key, default_pair_sorter_finder()); diff --git a/include/rstl/functional.hpp b/include/rstl/functional.hpp index 14821a89..7fea8cb7 100644 --- a/include/rstl/functional.hpp +++ b/include/rstl/functional.hpp @@ -10,9 +10,12 @@ struct identity { template < typename T > struct less { - bool operator()(const T& a, const T& b) const { return a < b; } + bool operator()(const T& a, const T& b) const; // { return a < b; } }; +template < typename T > +bool less::operator()(const T& a, const T& b) const { return a < b; } + } // namespace rstl #endif // _RSTL_FUNCTIONAL diff --git a/include/rstl/iterator.hpp b/include/rstl/iterator.hpp index 6b53dec4..cd29d79e 100644 --- a/include/rstl/iterator.hpp +++ b/include/rstl/iterator.hpp @@ -21,7 +21,7 @@ typename It::difference_type __distance(It first, It last, forward_iterator_tag) } template < typename It > -inline typename It::difference_type distance(It first, It last) { +typename It::difference_type distance(It first, It last) { return __distance(first, last, typename It::iterator_category()); } @@ -33,7 +33,7 @@ void __advance(It& it, S count, forward_iterator_tag) { } template < typename It, typename S > -inline void advance(It& it, S count) { +void advance(It& it, S count) { return __advance(it, count, typename It::iterator_category()); } diff --git a/include/rstl/pointer_iterator.hpp b/include/rstl/pointer_iterator.hpp index eb2cbd2f..6f90f9e9 100644 --- a/include/rstl/pointer_iterator.hpp +++ b/include/rstl/pointer_iterator.hpp @@ -128,12 +128,12 @@ struct const_counting_iterator { }; template < typename It > -inline typename It::difference_type __distance(It first, It last, random_access_iterator_tag) { +typename It::difference_type __distance(It first, It last, random_access_iterator_tag) { return last - first; } template < typename It, typename S > -inline void __advance(It& it, S count, random_access_iterator_tag) { +void __advance(It& it, S count, random_access_iterator_tag) { it += count; }