container traits information

Hi,
Is there any boost utility which statically determines if a template
parameter is const or not? ( MPL library ?)
I need to design something like boost::sub_range, but little different
(It will iterate over arbitrary sequence stored in a vector form, rather
than a sequence stored in pair form).
like,
template<typename C>
class index_range{
private:
C* container_;
std::vector

abir basak wrote:
Hi, Is there any boost utility which statically determines if a template parameter is const or not? ( MPL library ?)
I need to design something like boost::sub_range, but little different (It will iterate over arbitrary sequence stored in a vector form, rather than a sequence stored in pair form). like, template<typename C> class index_range{ private: C* container_; std::vector
index_; }; container & index will be passed through constructor. Now if C is const container it will return const_reference etc. Thus what is needed is something like, container_traits<const std::vector>::iterator is a const_iterator while container_traitsstd::vector::iterator is a iterator etc.
What is wrong with boost::range_iterator<C>::type ? -Thorsten

Thorsten Ottosen wrote:
abir basak wrote:
Hi, Is there any boost utility which statically determines if a template parameter is const or not? ( MPL library ?)
I need to design something like boost::sub_range, but little different (It will iterate over arbitrary sequence stored in a vector form, rather than a sequence stored in pair form). like, template<typename C> class index_range{ private: C* container_; std::vector
index_; }; container & index will be passed through constructor. Now if C is const container it will return const_reference etc. Thus what is needed is something like, container_traits<const std::vector>::iterator is a const_iterator while container_traitsstd::vector::iterator is a iterator etc.
What is wrong with boost::range_iterator<C>::type ?
Nothing wrong! This is exactly what I was looking for. Thanks for pointing it out! amazing library! abir
-Thorsten
-- Abir Basak, Member IEEE Software Engineer, Read Ink Technologies B. Tech, IIT Kharagpur email: abir@abirbasak.com homepage: www.abirbasak.com

abir basak wrote:
Thorsten Ottosen wrote:
abir basak wrote:
Hi, Is there any boost utility which statically determines if a template parameter is const or not? ( MPL library ?)
I need to design something like boost::sub_range, but little different (It will iterate over arbitrary sequence stored in a vector form, rather than a sequence stored in pair form). like, template<typename C> class index_range{ private: C* container_; std::vector
index_; }; container & index will be passed through constructor. Now if C is const container it will return const_reference etc. Thus what is needed is something like, container_traits<const std::vector>::iterator is a const_iterator while container_traitsstd::vector::iterator is a iterator etc. What is wrong with boost::range_iterator<C>::type ?
Nothing wrong! This is exactly what I was looking for. Thanks for pointing it out! amazing library!
Though I'm not sure about what you want, 'boost::permutation_iterator' can assist? http://www.boost.org/libs/iterator/doc/permutation_iterator.html -- Shunsuke Sogame
participants (3)
-
abir basak
-
shunsuke
-
Thorsten Ottosen