Move Vec<T>::const_iterator definition out of line
diff --git a/book/src/binding/vec.md b/book/src/binding/vec.md
index f3056fb..88d49d3 100644
--- a/book/src/binding/vec.md
+++ b/book/src/binding/vec.md
@@ -39,27 +39,29 @@
template <typename... Args>
void emplace_back(Args &&... args);
- class const_iterator final {
- public:
- using difference_type = ptrdiff_t;
- using value_type = typename std::add_const<T>::type;
- using pointer =
- typename std::add_pointer<typename std::add_const<T>::type>::type;
- using reference = typename std::add_lvalue_reference<
- typename std::add_const<T>::type>::type;
- using iterator_category = std::forward_iterator_tag;
-
- const T &operator*() const noexcept;
- const T *operator->() const noexcept;
- const_iterator &operator++() noexcept;
- const_iterator operator++(int) noexcept;
- bool operator==(const const_iterator &) const noexcept;
- bool operator!=(const const_iterator &) const noexcept;
- };
-
+ class const_iterator;
const_iterator begin() const noexcept;
const_iterator end() const noexcept;
};
+
+template <typename T>
+class Vec<T>::const_iterator final {
+public:
+ using difference_type = ptrdiff_t;
+ using value_type = typename std::add_const<T>::type;
+ using pointer =
+ typename std::add_pointer<typename std::add_const<T>::type>::type;
+ using reference = typename std::add_lvalue_reference<
+ typename std::add_const<T>::type>::type;
+ using iterator_category = std::forward_iterator_tag;
+
+ const T &operator*() const noexcept;
+ const T *operator->() const noexcept;
+ const_iterator &operator++() noexcept;
+ const_iterator operator++(int) noexcept;
+ bool operator==(const const_iterator &) const noexcept;
+ bool operator!=(const const_iterator &) const noexcept;
+};
#
# } // namespace rust
```
diff --git a/include/cxx.h b/include/cxx.h
index 0c91857..d1ab3c7 100644
--- a/include/cxx.h
+++ b/include/cxx.h
@@ -197,29 +197,7 @@
template <typename... Args>
void emplace_back(Args &&... args);
- class const_iterator final {
- public:
- using difference_type = ptrdiff_t;
- using value_type = typename std::add_const<T>::type;
- using pointer =
- typename std::add_pointer<typename std::add_const<T>::type>::type;
- using reference = typename std::add_lvalue_reference<
- typename std::add_const<T>::type>::type;
- using iterator_category = std::forward_iterator_tag;
-
- const T &operator*() const noexcept;
- const T *operator->() const noexcept;
- const_iterator &operator++() noexcept;
- const_iterator operator++(int) noexcept;
- bool operator==(const const_iterator &) const noexcept;
- bool operator!=(const const_iterator &) const noexcept;
-
- private:
- friend class Vec;
- const void *pos;
- size_t stride;
- };
-
+ class const_iterator;
const_iterator begin() const noexcept;
const_iterator end() const noexcept;
@@ -235,6 +213,30 @@
// Size and alignment statically verified by rust_vec.rs.
std::array<uintptr_t, 3> repr;
};
+
+template <typename T>
+class Vec<T>::const_iterator final {
+public:
+ using difference_type = ptrdiff_t;
+ using value_type = typename std::add_const<T>::type;
+ using pointer =
+ typename std::add_pointer<typename std::add_const<T>::type>::type;
+ using reference = typename std::add_lvalue_reference<
+ typename std::add_const<T>::type>::type;
+ using iterator_category = std::forward_iterator_tag;
+
+ const T &operator*() const noexcept;
+ const T *operator->() const noexcept;
+ const_iterator &operator++() noexcept;
+ const_iterator operator++(int) noexcept;
+ bool operator==(const const_iterator &) const noexcept;
+ bool operator!=(const const_iterator &) const noexcept;
+
+private:
+ friend class Vec;
+ const void *pos;
+ size_t stride;
+};
#endif // CXXBRIDGE1_RUST_VEC
#ifndef CXXBRIDGE1_RUST_FN