Created
March 24, 2010 17:33
-
-
Save dwaite/342528 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <list> | |
#include <stdexcept> | |
template <class T, class Allocator = std::allocator<T> > | |
class my_list : public std::list<T,Allocator> { | |
public: | |
typedef typename std::list<T,Allocator>::reference reference; | |
typedef typename std::list<T,Allocator>::const_reference const_reference; | |
reference back() { | |
if (this->empty()) { | |
throw std::runtime_error("No entries in list, back not possible"); | |
} | |
return std::list<T,Allocator>::back(); | |
} | |
const_reference back() const { | |
if (this->empty()) { | |
throw std::runtime_error("blah blah"); | |
} | |
return std::list<T,Allocator>::back(); | |
} | |
}; | |
int main() { | |
my_list<int> foo; | |
foo.back(); | |
return -1; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment