Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
3999d792
Unverified
Commit
3999d792
authored
Aug 02, 2022
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
const iterator construction from non-const iterator
parent
4db37327
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
15 deletions
+48
-15
include/cif++/v2/category.hpp
+1
-1
include/cif++/v2/iterator.hpp
+4
-1
include/cif++/v2/row.hpp
+21
-13
test/unit-v2-test.cpp
+22
-0
No files found.
include/cif++/v2/category.hpp
View file @
3999d792
...
...
@@ -144,7 +144,7 @@ class category_t
,
m_columns
(
rhs
.
m_columns
)
{
for
(
auto
r
=
rhs
.
m_head
;
r
!=
nullptr
;
r
=
r
->
m_next
)
insert_impl
(
c
end
(),
clone_row
(
*
r
));
insert_impl
(
end
(),
clone_row
(
*
r
));
}
category_t
(
category_t
&&
rhs
)
...
...
include/cif++/v2/iterator.hpp
View file @
3999d792
...
...
@@ -55,7 +55,10 @@ class iterator_impl
using
pointer
=
std
::
conditional_t
<
N
==
0
,
row_handle_type
,
value_type
*>
;
using
reference
=
std
::
conditional_t
<
N
==
0
,
row_handle_type
,
value_type
&>
;
iterator_impl
(
const
iterator_impl
&
rhs
)
iterator_impl
(
const
iterator_impl
&
rhs
)
=
default
;
template
<
typename
C2
,
typename
...
T2s
>
iterator_impl
(
const
iterator_impl
<
C2
,
T2s
...
>
&
rhs
)
:
m_category
(
rhs
.
m_category
)
,
m_current
(
rhs
.
m_current
)
,
m_value
(
rhs
.
m_value
)
...
...
include/cif++/v2/row.hpp
View file @
3999d792
...
...
@@ -31,7 +31,8 @@
namespace
cif
::
v2
{
template
<
typename
>
class
row_handle
;
template
<
typename
>
class
row_handle
;
namespace
detail
{
...
...
@@ -39,8 +40,7 @@ namespace detail
// some helper classes to help create tuple result types
template
<
typename
Category
,
typename
...
C
>
typename
...
C
>
struct
get_row_result
{
using
category_type
=
Category
;
...
...
@@ -102,7 +102,7 @@ namespace detail
std
::
tuple
<
Ts
...
>
m_value
;
};
}
}
// namespace detail
template
<
typename
...
Ts
>
auto
tie
(
Ts
&
...
v
)
...
...
@@ -113,26 +113,36 @@ auto tie(Ts &...v)
// --------------------------------------------------------------------
/// \brief row_handle is the way to access data in rows
template
<
typename
Category
>
template
<
typename
Category
>
class
row_handle
{
public
:
using
category_type
=
Category
;
using
row_type
=
std
::
conditional_t
<
std
::
is_const_v
<
category_type
>
,
const
typename
category_type
::
row
,
typename
category_type
::
row
>
;
template
<
typename
>
friend
class
row_handle
;
row_handle
()
=
default
;
row_handle
(
const
row_handle
&
)
=
default
;
row_handle
(
row_handle
&&
)
=
default
;
row_handle
&
operator
=
(
const
row_handle
&
)
=
default
;
row_handle
&
operator
=
(
row_handle
&&
)
=
default
;
template
<
typename
C2
>
row_handle
(
const
row_handle
<
C2
>
&
rhs
)
:
m_cat
(
rhs
.
m_cat
)
,
m_row
(
rhs
.
m_row
)
{
}
row_handle
(
category_type
&
cat
,
row_type
&
row
)
:
m_cat
(
&
cat
)
,
m_row
(
&
row
)
{}
,
m_row
(
&
row
)
{
}
explicit
operator
bool
()
const
{
...
...
@@ -177,7 +187,6 @@ class row_handle
}
private
:
uint32_t
get_column_ix
(
std
::
string_view
name
)
const
{
return
m_cat
->
get_column_ix
(
name
);
...
...
@@ -187,5 +196,4 @@ class row_handle
row_type
*
m_row
=
nullptr
;
};
}
\ No newline at end of file
}
//
namespace
cif
::
v2
\ No newline at end of file
test/unit-v2-test.cpp
View file @
3999d792
...
...
@@ -240,6 +240,28 @@ BOOST_AUTO_TEST_CASE(c_2)
BOOST_CHECK_EQUAL
(
c
.
size
(),
3
);
}
BOOST_AUTO_TEST_CASE
(
ci_1
)
{
cif
::
v2
::
category
c
(
"foo"
);
c
.
emplace
({{
"id"
,
1
},
{
"s"
,
"aap"
}});
c
.
emplace
({{
"id"
,
2
},
{
"s"
,
"noot"
}});
c
.
emplace
({{
"id"
,
3
},
{
"s"
,
"mies"
}});
cif
::
v2
::
category
::
iterator
i1
=
c
.
begin
();
cif
::
v2
::
category
::
const_iterator
i2
=
c
.
cbegin
();
cif
::
v2
::
category
::
const_iterator
i3
=
c
.
begin
();
cif
::
v2
::
category
::
const_iterator
i4
=
i2
;
cif
::
v2
::
category
::
const_iterator
i5
=
i1
;
BOOST_CHECK
(
i1
==
i2
);
BOOST_CHECK
(
i1
==
i3
);
BOOST_CHECK
(
i1
==
i4
);
BOOST_CHECK
(
i1
==
i5
);
}
// --------------------------------------------------------------------
// BOOST_AUTO_TEST_CASE(f_1)
...
...
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