Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
e3b17541
Unverified
Commit
e3b17541
authored
Oct 14, 2019
by
Kenton Varda
Committed by
GitHub
Oct 14, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #895 from vlovich/fix-kj-iterator
Add compat/std-iterator.h
parents
8a624a62
8fc9857a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
10 deletions
+42
-10
std-iterator.h
c++/src/capnp/compat/std-iterator.h
+39
-0
list.h
c++/src/capnp/list.h
+3
-10
No files found.
c++/src/capnp/compat/std-iterator.h
0 → 100644
View file @
e3b17541
// Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
// Licensed under the MIT License:
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#pragma once
// This exposes IndexingIterator as something compatible with std::iterator so that things like
// std::copy work with List::begin/List::end.
// Make sure that if this header is before list.h by the user it includes it to make
// IndexingIterator visible to avoid brittle header problems.
#include "../list.h"
#include <iterator>
namespace
std
{
template
<
typename
Container
,
typename
Element
>
struct
iterator_traits
<
capnp
::
_
::
IndexingIterator
<
Container
,
Element
>>
:
public
std
::
iterator
<
std
::
random_access_iterator_tag
,
Element
,
int
>
{};
}
// namespace std
c++/src/capnp/list.h
View file @
e3b17541
...
...
@@ -28,9 +28,6 @@
#include "layout.h"
#include "orphan.h"
#include <initializer_list>
#ifdef KJ_STD_COMPAT
#include <iterator>
#endif // KJ_STD_COMPAT
namespace
capnp
{
namespace
_
{
// private
...
...
@@ -51,6 +48,8 @@ private:
T
value
;
};
// By default this isn't compatible with STL algorithms. To add STL support either define
// KJ_STD_COMPAT at the top of your compilation unit or include capnp/compat/std-iterator.h.
template
<
typename
Container
,
typename
Element
>
class
IndexingIterator
{
public
:
...
...
@@ -549,11 +548,5 @@ private:
}
// namespace capnp
#ifdef KJ_STD_COMPAT
namespace
std
{
template
<
typename
Container
,
typename
Element
>
struct
iterator_traits
<
capnp
::
_
::
IndexingIterator
<
Container
,
Element
>>
:
public
std
::
iterator
<
std
::
random_access_iterator_tag
,
Element
,
int
>
{};
}
// namespace std
#include "compat/std-iterator.h"
#endif // KJ_STD_COMPAT
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