C++ Template Metaprogramming
Solutions to the exercises throughout the book
Loading...
Searching...
No Matches

Encapsulate solution for Exercise 4-5. More...

Functions

template<typename Container , typename Value >
boost::mpl::if_< boost::is_const< Container >, typenameContainer::const_iterator, typenameContainer::iterator >::type container_find (Container &c, Value const &v)
 Executes std::find across an entire container.
 

Detailed Description

Encapsulate solution for Exercise 4-5.

Function Documentation

◆ container_find()

template<typename Container , typename Value >
boost::mpl::if_< boost::is_const< Container >, typenameContainer::const_iterator, typenameContainer::iterator >::type exercise_4_5::container_find ( Container &  c,
Value const &  v 
)

Executes std::find across an entire container.

This method is specially designed to return a const_iterator if the container instance is constant, and non-const otherwise.

Template Parameters
ContainerThe input container type.
ValueA value type suitable for the std::find algorithm when used with Container type containers.
Parameters
[in]cThe container to search.
[in]vThe value to search for.
Returns
An iterator to the position of the first element found to be equivalent to v. The type is dynamically selected based on the container type.

Definition at line 70 of file exercise-4-5.hpp.