Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
972e3253
Commit
972e3253
authored
Jan 12, 2014
by
Davis King
Browse files
Made dlib::array usable in C++11 range based for loops by adding
begin() and end() methods.
parent
1e9a6297
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
dlib/array/array_kernel.h
dlib/array/array_kernel.h
+7
-0
dlib/array/array_kernel_abstract.h
dlib/array/array_kernel_abstract.h
+34
-0
No files found.
dlib/array/array_kernel.h
View file @
972e3253
...
@@ -177,6 +177,13 @@ namespace dlib
...
@@ -177,6 +177,13 @@ namespace dlib
T
&
item
T
&
item
);
);
typedef
T
*
iterator
;
typedef
const
T
*
const_iterator
;
iterator
begin
()
{
return
array_elements
;
}
const_iterator
begin
()
const
{
return
array_elements
;
}
iterator
end
()
{
return
array_elements
+
array_size
;
}
const_iterator
end
()
const
{
return
array_elements
+
array_size
;
}
private:
private:
typename
mem_manager
::
template
rebind
<
T
>
::
other
pool
;
typename
mem_manager
::
template
rebind
<
T
>
::
other
pool
;
...
...
dlib/array/array_kernel_abstract.h
View file @
972e3253
...
@@ -254,6 +254,40 @@ namespace dlib
...
@@ -254,6 +254,40 @@ namespace dlib
If an exception is thrown then it has no effect on *this.
If an exception is thrown then it has no effect on *this.
!*/
!*/
typedef
T
*
iterator
;
typedef
const
T
*
const_iterator
;
iterator
begin
(
);
/*!
ensures
- returns an iterator that points to the first element in this array or
end() if the array is empty.
!*/
const_iterator
begin
(
)
const
;
/*!
ensures
- returns a const iterator that points to the first element in this
array or end() if the array is empty.
!*/
iterator
end
(
);
/*!
ensures
- returns an iterator that points to one past the end of the array.
!*/
const_iterator
end
(
)
const
;
/*!
ensures
- returns a const iterator that points to one past the end of the
array.
!*/
private:
private:
// restricted functions
// restricted functions
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment