mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
Fixes type for all iterator::reference.
1. we have overloaded operator*() for all iterators, returning a value type T (not a reference). 2. we use the std::reverse_iterator, its operator*() returns a reference type, by default the reference type is T&. follow implement std::reverse_iterator::operator*() const are taken form VS2015: ```C++ // in class reverse_iterator reference operator*() const { // return designated value _RanIt _Tmp = current; return (*--_Tmp); } ``` The `_RanIt` is our base non reverse iterators, the type of `(*--_Tmp)` is `T`. and the `reference` is `T&`. This cause > warning C4172: returning address of local variable or temporary And it is bug. This commit specifies explicitly the 5th template argument for all our iterators base class like `std::iterator<tag,T, ptrdiff_t, T*, T>`. It make the `reference` to be actually `T` (the value type) and fixes the issue.
This commit is contained in:
parent
23f65602de
commit
a0b8b8f5e2
|
@ -33,7 +33,7 @@ namespace xlnt {
|
|||
class workbook;
|
||||
class worksheet;
|
||||
|
||||
class XLNT_CLASS const_worksheet_iterator : public std::iterator<std::bidirectional_iterator_tag, const worksheet>
|
||||
class XLNT_CLASS const_worksheet_iterator : public std::iterator<std::bidirectional_iterator_tag, const worksheet, ptrdiff_t, const worksheet*, const worksheet>
|
||||
{
|
||||
public:
|
||||
const_worksheet_iterator(const workbook &wb, std::size_t index);
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace xlnt {
|
|||
class workbook;
|
||||
class worksheet;
|
||||
|
||||
class XLNT_CLASS worksheet_iterator : public std::iterator<std::bidirectional_iterator_tag, worksheet>
|
||||
class XLNT_CLASS worksheet_iterator : public std::iterator<std::bidirectional_iterator_tag, worksheet, ptrdiff_t, worksheet*, worksheet>
|
||||
{
|
||||
public:
|
||||
worksheet_iterator(workbook &wb, std::size_t index);
|
||||
|
|
|
@ -37,7 +37,7 @@ class cell_reference;
|
|||
class range_reference;
|
||||
enum class major_order;
|
||||
|
||||
class XLNT_CLASS cell_iterator : public std::iterator<std::bidirectional_iterator_tag, cell>
|
||||
class XLNT_CLASS cell_iterator : public std::iterator<std::bidirectional_iterator_tag, cell, ptrdiff_t, cell*, cell>
|
||||
{
|
||||
public:
|
||||
cell_iterator(worksheet ws, const cell_reference &start_cell);
|
||||
|
|
|
@ -37,7 +37,7 @@ class cell_reference;
|
|||
class range_reference;
|
||||
enum class major_order;
|
||||
|
||||
class XLNT_CLASS const_cell_iterator : public std::iterator<std::bidirectional_iterator_tag, const cell>
|
||||
class XLNT_CLASS const_cell_iterator : public std::iterator<std::bidirectional_iterator_tag, const cell, ptrdiff_t, const cell*, const cell>
|
||||
{
|
||||
public:
|
||||
const_cell_iterator(worksheet ws, const cell_reference &start_cell);
|
||||
|
|
|
@ -40,7 +40,7 @@ struct worksheet_impl;
|
|||
/// A const version of range_iterator which does not allow modification
|
||||
/// to the dereferenced cell_vector.
|
||||
/// </summary>
|
||||
class XLNT_CLASS const_range_iterator : public std::iterator<std::bidirectional_iterator_tag, const cell_vector>
|
||||
class XLNT_CLASS const_range_iterator : public std::iterator<std::bidirectional_iterator_tag, const cell_vector, ptrdiff_t, const cell_vector*, const cell_vector>
|
||||
{
|
||||
public:
|
||||
const_range_iterator(
|
||||
|
|
|
@ -40,7 +40,7 @@ struct worksheet_impl;
|
|||
/// An iterator used by worksheet and range for traversing
|
||||
/// a 2D grid of cells by row/column then across that row/column.
|
||||
/// </summary>
|
||||
class XLNT_CLASS range_iterator : public std::iterator<std::bidirectional_iterator_tag, cell_vector>
|
||||
class XLNT_CLASS range_iterator : public std::iterator<std::bidirectional_iterator_tag, cell_vector, ptrdiff_t, cell_vector*, cell_vector>
|
||||
{
|
||||
public:
|
||||
range_iterator(worksheet &ws, const range_reference &start_cell, major_order order = major_order::row);
|
||||
|
|
Loading…
Reference in New Issue
Block a user