summaryrefslogtreecommitdiff
path: root/src/range
diff options
context:
space:
mode:
Diffstat (limited to 'src/range')
-rw-r--r--src/range/fwd.hpp29
-rw-r--r--src/range/slice.cpp5
-rw-r--r--src/range/slice.hpp18
-rw-r--r--src/range/slice.tcc6
-rw-r--r--src/range/slice_test.cpp4
5 files changed, 51 insertions, 11 deletions
diff --git a/src/range/fwd.hpp b/src/range/fwd.hpp
new file mode 100644
index 0000000..646eadb
--- /dev/null
+++ b/src/range/fwd.hpp
@@ -0,0 +1,29 @@
+#pragma once
+// range/fwd.hpp - list of type names for range lib
+//
+// Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com>
+//
+// This file is part of The Mana World (Athena server)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "../sanity.hpp"
+
+
+namespace tmwa
+{
+// meh, add more when I feel like it
+template<class T>
+class Slice;
+} // namespace tmwa
diff --git a/src/range/slice.cpp b/src/range/slice.cpp
index 5e00233..f93c19f 100644
--- a/src/range/slice.cpp
+++ b/src/range/slice.cpp
@@ -19,3 +19,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "../poison.hpp"
+
+
+namespace tmwa
+{
+} // namespace tmwa
diff --git a/src/range/slice.hpp b/src/range/slice.hpp
index f645595..da52e5f 100644
--- a/src/range/slice.hpp
+++ b/src/range/slice.hpp
@@ -1,5 +1,4 @@
-#ifndef TMWA_GENERIC_SLICE_HPP
-#define TMWA_GENERIC_SLICE_HPP
+#pragma once
// slice.hpp - a borrowed array
//
// Copyright © 2011-2014 Ben Longbons <b.r.longbons@gmail.com>
@@ -19,14 +18,16 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-# include "../sanity.hpp"
+#include "fwd.hpp"
-# include <cstddef>
+#include <cstddef>
-# include <type_traits>
+#include <type_traits>
+#include <vector>
-# include <vector>
+namespace tmwa
+{
template<class T>
class Slice
{
@@ -68,7 +69,6 @@ public:
Slice pslice(size_t b, size_t e) const;
Slice islice(iterator b, iterator e) const;
};
+} // namespace tmwa
-# include "slice.tcc"
-
-#endif // TMWA_GENERIC_SLICE_HPP
+#include "slice.tcc"
diff --git a/src/range/slice.tcc b/src/range/slice.tcc
index 3a1ceb5..a1c136f 100644
--- a/src/range/slice.tcc
+++ b/src/range/slice.tcc
@@ -1,4 +1,4 @@
-// strings/base.tcc - Inline functions for strings/base.hpp
+// ranges/slice.tcc - Inline functions for strings/base.hpp
//
// Copyright © 2013 Ben Longbons <b.r.longbons@gmail.com>
//
@@ -19,8 +19,9 @@
#include <cassert>
-#include <algorithm>
+namespace tmwa
+{
// simple pointer-wrapping iterator
template<class T>
class Slice<T>::iterator
@@ -214,3 +215,4 @@ Slice<T> Slice<T>::islice(iterator b, iterator e) const
{
return Slice(&*b, &*e);
}
+} // namespace tmwa
diff --git a/src/range/slice_test.cpp b/src/range/slice_test.cpp
index f59bf84..d31d973 100644
--- a/src/range/slice_test.cpp
+++ b/src/range/slice_test.cpp
@@ -22,6 +22,9 @@
#include "../poison.hpp"
+
+namespace tmwa
+{
TEST(slice, slice)
{
int init[] = {1, 2, 3, 4, 5};
@@ -107,3 +110,4 @@ TEST(slice, cast)
EXPECT_EQ(foos.size(), slice.size());
EXPECT_EQ(&foos.end()[-1], &slice.end()[-1]);
}
+} // namespace tmwa