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
54c167f4
Commit
54c167f4
authored
Jun 26, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add dictionary::emplace and fix operators
parent
1d99dc5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
13 deletions
+32
-13
libcaf_core/caf/dictionary.hpp
libcaf_core/caf/dictionary.hpp
+32
-13
No files found.
libcaf_core/caf/dictionary.hpp
View file @
54c167f4
...
...
@@ -177,23 +177,37 @@ public:
// -- insertion --------------------------------------------------------------
template
<
class
T
>
iterator_bool_pair
insert
(
string_view
key
,
T
&&
value
)
{
template
<
class
K
,
class
T
>
iterator_bool_pair
emplace
(
K
&&
key
,
T
&&
value
)
{
auto
i
=
lower_bound
(
key
);
if
(
i
==
end
())
return
xs_
.
emplace
(
copy
(
key
),
std
::
forward
<
T
>
(
value
));
return
xs_
.
emplace
(
copy
(
std
::
forward
<
K
>
(
key
)
),
std
::
forward
<
T
>
(
value
));
if
(
i
->
first
==
key
)
return
{
i
,
false
};
return
{
xs_
.
emplace_hint
(
i
,
copy
(
key
),
std
::
forward
<
T
>
(
value
)),
true
};
return
{
xs_
.
emplace_hint
(
i
,
copy
(
std
::
forward
<
K
>
(
key
)),
std
::
forward
<
T
>
(
value
)),
true
};
}
template
<
class
T
>
iterator
insert
(
iterator
hint
,
string_view
key
,
T
&&
value
)
{
iterator_bool_pair
insert
(
string_view
key
,
T
&&
value
)
{
return
emplace
(
key
,
std
::
forward
<
T
>
(
value
));
}
template
<
class
K
,
class
T
>
iterator
emplace_hint
(
iterator
hint
,
K
&&
key
,
T
&&
value
)
{
if
(
hint
==
end
()
||
hint
->
first
>
key
)
return
xs_
.
emplace
(
copy
(
key
),
std
::
forward
<
T
>
(
value
)).
first
;
return
xs_
.
emplace
(
copy
(
std
::
forward
<
K
>
(
key
)),
std
::
forward
<
T
>
(
value
))
.
first
;
if
(
hint
->
first
==
key
)
return
hint
;
return
xs_
.
emplace_hint
(
hint
,
copy
(
key
),
std
::
forward
<
T
>
(
value
));
return
xs_
.
emplace_hint
(
hint
,
copy
(
std
::
forward
<
K
>
(
key
)),
std
::
forward
<
T
>
(
value
));
}
template
<
class
T
>
iterator
insert
(
iterator
hint
,
string_view
key
,
T
&&
value
)
{
return
emplace_hint
(
hint
,
key
,
std
::
forward
<
T
>
(
value
));
}
template
<
class
T
>
...
...
@@ -281,42 +295,47 @@ private:
return
std
::
string
{
str
.
begin
(),
str
.
end
()};
}
// Moves the content of `str` into a new string.
static
inline
std
::
string
copy
(
std
::
string
str
)
{
return
str
;
}
map_type
xs_
;
};
// @relates dictionary
template
<
class
T
>
bool
operator
==
(
const
dictionary
<
T
>&
xs
,
const
dictionary
<
int
>&
ys
)
{
bool
operator
==
(
const
dictionary
<
T
>&
xs
,
const
dictionary
<
T
>&
ys
)
{
return
xs
.
container
()
==
ys
.
container
();
}
// @relates dictionary
template
<
class
T
>
bool
operator
!=
(
const
dictionary
<
T
>&
xs
,
const
dictionary
<
int
>&
ys
)
{
bool
operator
!=
(
const
dictionary
<
T
>&
xs
,
const
dictionary
<
T
>&
ys
)
{
return
xs
.
container
()
!=
ys
.
container
();
}
// @relates dictionary
template
<
class
T
>
bool
operator
<
(
const
dictionary
<
T
>&
xs
,
const
dictionary
<
int
>&
ys
)
{
bool
operator
<
(
const
dictionary
<
T
>&
xs
,
const
dictionary
<
T
>&
ys
)
{
return
xs
.
container
()
<
ys
.
container
();
}
// @relates dictionary
template
<
class
T
>
bool
operator
<=
(
const
dictionary
<
T
>&
xs
,
const
dictionary
<
int
>&
ys
)
{
bool
operator
<=
(
const
dictionary
<
T
>&
xs
,
const
dictionary
<
T
>&
ys
)
{
return
xs
.
container
()
<=
ys
.
container
();
}
// @relates dictionary
template
<
class
T
>
bool
operator
>
(
const
dictionary
<
T
>&
xs
,
const
dictionary
<
int
>&
ys
)
{
bool
operator
>
(
const
dictionary
<
T
>&
xs
,
const
dictionary
<
T
>&
ys
)
{
return
xs
.
container
()
>
ys
.
container
();
}
// @relates dictionary
template
<
class
T
>
bool
operator
>=
(
const
dictionary
<
T
>&
xs
,
const
dictionary
<
int
>&
ys
)
{
bool
operator
>=
(
const
dictionary
<
T
>&
xs
,
const
dictionary
<
T
>&
ys
)
{
return
xs
.
container
()
>=
ys
.
container
();
}
...
...
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