Commit 4dfeb7e1 authored by Davis King's avatar Davis King

Made alias_tensor usable when it is const.

parent 7ba8ea9c
...@@ -615,7 +615,7 @@ namespace dlib ...@@ -615,7 +615,7 @@ namespace dlib
alias_tensor_instance operator() ( alias_tensor_instance operator() (
tensor& t, tensor& t,
size_t offset size_t offset
) ) const
{ {
DLIB_CASSERT(offset+size() <= t.size()); DLIB_CASSERT(offset+size() <= t.size());
...@@ -637,7 +637,7 @@ namespace dlib ...@@ -637,7 +637,7 @@ namespace dlib
alias_tensor_const_instance operator() ( alias_tensor_const_instance operator() (
const tensor& t, const tensor& t,
size_t offset size_t offset
) ) const
{ {
alias_tensor_const_instance temp; alias_tensor_const_instance temp;
temp.inst = (*this)(const_cast<tensor&>(t),offset); temp.inst = (*this)(const_cast<tensor&>(t),offset);
...@@ -645,7 +645,7 @@ namespace dlib ...@@ -645,7 +645,7 @@ namespace dlib
} }
private: private:
alias_tensor_instance inst; mutable alias_tensor_instance inst;
}; };
inline void serialize(const alias_tensor& item, std::ostream& out) inline void serialize(const alias_tensor& item, std::ostream& out)
......
...@@ -663,7 +663,7 @@ namespace dlib ...@@ -663,7 +663,7 @@ namespace dlib
alias_tensor_instance operator() ( alias_tensor_instance operator() (
tensor& t, tensor& t,
size_t offset size_t offset
); ) const;
/*! /*!
requires requires
- offset+size() <= t.size() - offset+size() <= t.size()
...@@ -684,7 +684,7 @@ namespace dlib ...@@ -684,7 +684,7 @@ namespace dlib
alias_tensor_const_instance operator() ( alias_tensor_const_instance operator() (
const tensor& t, const tensor& t,
size_t offset size_t offset
); ) const;
/*! /*!
requires requires
- offset+size() <= t.size() - offset+size() <= t.size()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment