Skip to content
Snippets Groups Projects
Commit 29492ada authored by Charles Leggett's avatar Charles Leggett
Browse files

Merge branch 'fix_vector_of_const' into 'master'

added correct vector_of_const_::operator[] and ::at

See merge request !710
parents f92ca666 9c82f074
No related branches found
No related tags found
1 merge request!710added correct vector_of_const_::operator[] and ::at
Pipeline #480800 passed
......@@ -317,12 +317,31 @@ namespace Gaudi
iterator begin() const { return m_containers.begin(); }
iterator end() const { return m_containers.end(); }
size_type size() const { return m_containers.size(); }
const Container& operator[]( size_type i ) const { return *m_containers[i]; }
const Container& at( size_type i ) const
template <typename X = Container>
std::enable_if_t<!std::is_pointer<X>::value, ref_t> operator[]( size_type i ) const
{
return *m_containers[i];
}
template <typename X = Container>
std::enable_if_t<std::is_pointer<X>::value, ptr_t> operator[]( size_type i ) const
{
return m_containers[i];
}
template <typename X = Container>
std::enable_if_t<!std::is_pointer<X>::value, ref_t> at( size_type i ) const
{
if ( UNLIKELY( i >= size() ) ) throw std::out_of_range{"vector_of_const_::at"};
return *m_containers[i];
}
template <typename X = Container>
std::enable_if_t<std::is_pointer<X>::value, ptr_t> at( size_type i ) const
{
return m_containers[i];
}
bool is_null( size_type i ) const { return !m_containers[i]; }
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment