Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
ed94c0e0
Commit
ed94c0e0
authored
Jul 10, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix build on MSVC
parent
2f923b93
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
libcaf_core/caf/ipv6_address.hpp
libcaf_core/caf/ipv6_address.hpp
+3
-1
libcaf_core/src/ipv6_address.cpp
libcaf_core/src/ipv6_address.cpp
+9
-9
No files found.
libcaf_core/caf/ipv6_address.hpp
View file @
ed94c0e0
...
@@ -42,6 +42,8 @@ public:
...
@@ -42,6 +42,8 @@ public:
using
array_type
=
std
::
array
<
uint8_t
,
num_bytes
>
;
using
array_type
=
std
::
array
<
uint8_t
,
num_bytes
>
;
using
u16_array_type
=
std
::
array
<
uint16_t
,
8
>
;
using
uint16_ilist
=
std
::
initializer_list
<
uint16_t
>
;
using
uint16_ilist
=
std
::
initializer_list
<
uint16_t
>
;
// -- constructors, destructors, and assignment operators --------------------
// -- constructors, destructors, and assignment operators --------------------
...
@@ -121,7 +123,7 @@ private:
...
@@ -121,7 +123,7 @@ private:
union
{
union
{
std
::
array
<
uint64_t
,
2
>
half_segments_
;
std
::
array
<
uint64_t
,
2
>
half_segments_
;
std
::
array
<
uint32_t
,
4
>
quad_segments_
;
std
::
array
<
uint32_t
,
4
>
quad_segments_
;
std
::
array
<
uint16_t
,
8
>
oct_segments_
;
u16_array_type
oct_segments_
;
array_type
bytes_
;
array_type
bytes_
;
};
};
};
};
...
...
libcaf_core/src/ipv6_address.cpp
View file @
ed94c0e0
...
@@ -146,29 +146,29 @@ bool ipv6_address::is_loopback() const noexcept {
...
@@ -146,29 +146,29 @@ bool ipv6_address::is_loopback() const noexcept {
namespace
{
namespace
{
using
u16_iterator
=
const
uint16_t
*
;
using
u16_iterator
=
ipv6_address
::
u16_array_type
::
const_iterator
;
using
u16_range
=
std
::
pair
<
u16_iterator
,
u16_iterator
>
;
using
u16_range
=
std
::
pair
<
u16_iterator
,
u16_iterator
>
;
u16_range
longest_streak
(
u16_iterator
first
,
u16_iterator
last
)
{
u16_range
longest_streak
(
u16_iterator
first
,
u16_iterator
last
)
{
auto
zero
=
[](
uint16_t
x
,
uint16_t
y
)
{
auto
two_zeros
=
[](
uint16_t
x
,
uint16_t
y
)
{
return
x
==
0
&&
y
==
0
;
return
x
==
0
&&
y
==
0
;
};
};
auto
not_zero
=
[](
uint16_t
x
)
{
auto
not_zero
=
[](
uint16_t
x
)
{
return
x
!=
0
;
return
x
!=
0
;
};
};
u16_range
result
;
u16_range
result
;
result
.
first
=
std
::
adjacent_find
(
first
,
last
,
zero
);
result
.
first
=
std
::
adjacent_find
(
first
,
last
,
two_zeros
);
if
(
result
.
first
==
last
)
if
(
result
.
first
==
last
)
return
{
last
,
last
};
return
{
last
,
last
};
result
.
second
=
std
::
find_if
(
result
.
first
+
2
,
last
,
not_zero
);
result
.
second
=
std
::
find_if
(
result
.
first
+
2
,
last
,
not_zero
);
if
(
result
.
second
==
last
)
if
(
result
.
second
==
last
)
return
result
;
return
result
;
auto
next_streak
=
longest_streak
(
result
.
second
,
last
);
auto
next_streak
=
longest_streak
(
result
.
second
,
last
);
auto
distanc
e
=
[](
u16_range
x
)
{
auto
range_siz
e
=
[](
u16_range
x
)
{
return
std
::
distance
(
x
.
first
,
x
.
second
);
return
std
::
distance
(
x
.
first
,
x
.
second
);
};
};
return
distance
(
result
)
>=
distanc
e
(
next_streak
)
?
result
:
next_streak
;
return
range_size
(
result
)
>=
range_siz
e
(
next_streak
)
?
result
:
next_streak
;
}
}
}
// namespace <anonymous>
}
// namespace <anonymous>
...
@@ -188,16 +188,16 @@ std::string to_string(ipv6_address x) {
...
@@ -188,16 +188,16 @@ std::string to_string(ipv6_address x) {
};
};
auto
add_chunks
=
[
&
](
u16_iterator
i
,
u16_iterator
e
)
{
auto
add_chunks
=
[
&
](
u16_iterator
i
,
u16_iterator
e
)
{
if
(
i
!=
e
)
{
if
(
i
!=
e
)
{
add_chunk
(
*
i
++
);
add_chunk
(
*
i
);
for
(;
i
!=
e
;
++
i
)
{
for
(
++
i
;
i
!=
e
;
++
i
)
{
result
+=
':'
;
result
+=
':'
;
add_chunk
(
*
i
);
add_chunk
(
*
i
);
}
}
}
}
};
};
// Scan for the longest streak of 0 16-bit chunks for :: shorthand.
// Scan for the longest streak of 0 16-bit chunks for :: shorthand.
auto
first
=
x
.
oct_segments_
.
begin
();
auto
first
=
x
.
oct_segments_
.
c
begin
();
auto
last
=
x
.
oct_segments_
.
end
();
auto
last
=
x
.
oct_segments_
.
c
end
();
auto
streak
=
longest_streak
(
first
,
last
);
auto
streak
=
longest_streak
(
first
,
last
);
// Put it all together.
// Put it all together.
if
(
streak
.
first
==
last
)
{
if
(
streak
.
first
==
last
)
{
...
...
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