From 45f8f46dfa7a47b93c413bd861408512b6d3fae7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20K=C4=99dzia?= <Pawel.Kedzia@pwr.wroc.pl>
Date: Tue, 3 Jan 2012 09:43:11 +0100
Subject: [PATCH] While Corpus is empty, next_document in corpus returns empty
 shared_ptr to Document

---
 libcorpus2_whole/corpus.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/libcorpus2_whole/corpus.h b/libcorpus2_whole/corpus.h
index 3f1a55e..d00a326 100644
--- a/libcorpus2_whole/corpus.h
+++ b/libcorpus2_whole/corpus.h
@@ -51,9 +51,14 @@ public:
 	/// Next document in corpus
 	boost::shared_ptr<Document> next_document() {
 		if (!this->set_) {
-			this->set_ = true;
-			this->current_document_ = documents_.begin();
-
+			if (this->documents_.size() == 0) {
+				boost::shared_ptr<Document> tmp;
+				return tmp;
+			}
+			else {
+				this->set_ = true;
+				this->current_document_ = documents_.begin();
+			}
 		}
 		else {
 			current_document_++;
-- 
GitLab