summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorljfa <ljfa-ag@web.de>2015-09-22 15:21:16 +0200
committerljfa <ljfa-ag@web.de>2015-09-22 15:43:57 +0200
commit3f965312d61fac3970f1000ee6433cc154abcb6c (patch)
treed1a07e1e7970cf5e88a86452f3702f6f4850b0a5
parent9c63256baa6562c5e50431b555e1c3c8e867bdb7 (diff)
downloadProject-Tick-3f965312d61fac3970f1000ee6433cc154abcb6c.tar.gz
Project-Tick-3f965312d61fac3970f1000ee6433cc154abcb6c.zip
Explicitly instantiate and export templates in header
and move defintions of tag_array::at to header
-rw-r--r--include/tag_array.h10
-rw-r--r--include/tag_primitive.h8
-rw-r--r--src/tag_array.cpp16
3 files changed, 15 insertions, 19 deletions
diff --git a/include/tag_array.h b/include/tag_array.h
index c59249b571..be9591c0f3 100644
--- a/include/tag_array.h
+++ b/include/tag_array.h
@@ -32,7 +32,7 @@ namespace detail
{
///Meta-struct that holds the tag_type value for a specific array type
template<class T> struct get_array_type
- { static_assert(sizeof(T) != sizeof(T), "Invalid type paramter for tag_primitive, can only use byte or int"); };
+ { static_assert(sizeof(T) != sizeof(T), "Invalid type paramter for tag_array, can only use byte or int"); };
template<> struct get_array_type<int8_t> : public std::integral_constant<tag_type, tag_type::Byte_Array> {};
template<> struct get_array_type<int32_t> : public std::integral_constant<tag_type, tag_type::Int_Array> {};
@@ -73,8 +73,8 @@ public:
* @brief Accesses a value by index with bounds checking
* @throw std::out_of_range if the index is out of range
*/
- T& at(size_t i);
- T at(size_t i) const;
+ T& at(size_t i) { return data.at(i); }
+ T at(size_t i) const { return data.at(i); }
/**
* @brief Accesses a value by index
@@ -124,6 +124,10 @@ template<class T> bool operator!=(const tag_array<T>& lhs, const tag_array<T>& r
typedef tag_array<int8_t> tag_byte_array;
typedef tag_array<int32_t> tag_int_array;
+//Explicit instantiations
+template class NBT_EXPORT tag_array<int8_t>;
+template class NBT_EXPORT tag_array<int32_t>;
+
}
#endif // TAG_ARRAY_H_INCLUDED
diff --git a/include/tag_primitive.h b/include/tag_primitive.h
index 07ae985559..e3d5111e76 100644
--- a/include/tag_primitive.h
+++ b/include/tag_primitive.h
@@ -77,6 +77,14 @@ typedef tag_primitive<int64_t> tag_long;
typedef tag_primitive<float> tag_float;
typedef tag_primitive<double> tag_double;
+//Explicit instantiations
+template class NBT_EXPORT tag_primitive<int8_t>;
+template class NBT_EXPORT tag_primitive<int16_t>;
+template class NBT_EXPORT tag_primitive<int32_t>;
+template class NBT_EXPORT tag_primitive<int64_t>;
+template class NBT_EXPORT tag_primitive<float>;
+template class NBT_EXPORT tag_primitive<double>;
+
template<class T>
void tag_primitive<T>::read_payload(io::stream_reader& reader)
{
diff --git a/src/tag_array.cpp b/src/tag_array.cpp
index 3f073232d1..6173dbb1dd 100644
--- a/src/tag_array.cpp
+++ b/src/tag_array.cpp
@@ -25,18 +25,6 @@
namespace nbt
{
-template<class T>
-T& tag_array<T>::at(size_t i)
-{
- return data.at(i);
-}
-
-template<class T>
-T tag_array<T>::at(size_t i) const
-{
- return data.at(i);
-}
-
//Slightly different between byte_array and int_array
//Reading
template<>
@@ -103,8 +91,4 @@ void tag_array<int32_t>::write_payload(io::stream_writer& writer) const
writer.write_num(i);
}
-//Enforce template instantiations
-template class NBT_EXPORT tag_array<int8_t>;
-template class NBT_EXPORT tag_array<int32_t>;
-
}