Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Maintenance - Mise à jour mensuelle Lundi 6 Février entre 7h00 et 9h00
Open sidebar
Gauthier Quesnel
bits
Commits
55d470e2
Commit
55d470e2
authored
Mar 19, 2019
by
Gauthier Quesnel
Browse files
getopt: fix warning
parent
f50c525c
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/bits/array.hpp
0 → 100644
View file @
55d470e2
/*
* This file is part of VLE, a framework for multi-modeling, simulation
* and analysis of complex dynamical systems.
* https://www.vle-project.org
*
* Copyright (c) 2003-2018 Gauthier Quesnel <gauthier.quesnel@inra.fr>
* Copyright (c) 2003-2018 ULCO http://www.univ-littoral.fr
* Copyright (c) 2007-2018 INRA http://www.inra.fr
*
* See the AUTHORS or Authors.txt file for copyright owners and
* contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include
<type_traits>
namespace
vle
{
namespace
glvle
{
template
<
typename
T
>
struct
DataArray
<
T
>
{
struct
item
{
T
item
;
int
id
;
// (key << 16 | index) for alloced entries, (0 | nextFreeIndex)
// for free list entries
};
// allocs items (max 64k), then Clear()
void
init
(
int
count
);
// frees items
void
dispose
();
// resets data members, (runs destructors* on outstanding items,
// *optional)
void
clear
();
T
&
Alloc
();
// alloc (memclear* and/or construct*, *optional) an item from
// freeList or items[maxUsed++], sets id to (nextKey++ << 16) |
// index
void
Free
(
T
&
);
// puts entry on free list (uses id to store next)
int
GetID
(
T
&
);
// accessor to the id part if Item
T
&
Get
(
id
)
// return item[id & 0xFFFF];
T
*
TryToGet
(
id
);
// validates id, then returns item, returns null if invalid. for
// cases like AI references and others where 'the thing might have
// been deleted out from under me'
bool
Next
(
T
*&
);
// return next item where id & 0xFFFF0000 != 0 (ie items
// not on free list)
std
::
vector
<
item
>
items
;
Item
*
items
;
int
maxSize
;
// total size
int
maxUsed
;
// highest index ever alloced
int
count
;
// num alloced items
int
nextKey
;
// [1..2^16] (don't let == 0)
int
freeHead
;
// index of first free entry
};
template
<
typename
T
>
void
DataArray
<
T
>::
init
(
int
count
)
{
items
.
resize
(
static_cast
<
size_t
>
(
count
));
}
template
<
typename
T
>
void
DataArray
<
T
>::
dispose
()
{
items
.
resize
(
static_cast
<
size_t
>
(
0
));
items
.
shrink_to_fit
();
}
template
<
typename
T
,
true
>
void
Do_clear
(
std
::
vector
<
T
>&
items
)
{}
template
<
typename
T
,
false
>
void
Do_clear
(
std
::
vector
<
T
>&
items
)
{
std
::
for_each
(
std
::
begin
(
items
),
std
::
end
(
items
),
[](
auto
&
elem
)
{
elem
.
~
T
();
});
}
template
<
typename
T
>
void
DataArray
<
T
>::
clear
()
{
Do_clear
<
T
,
std
::
is_trivial
<
T
>::
value
>
(
items
);
}
template
<
typename
T
>
T
&
DataArray
<
T
>::
alloc
();
{}
// alloc (memclear* and/or construct*, *optional) an item from
// freeList or items[maxUsed++], sets id to (nextKey++ << 16) |
// index
}
// glvle
}
// vle
include/bits/getopt.hpp
View file @
55d470e2
...
...
@@ -262,7 +262,7 @@ getopt(int argc,
bool
next_arg
=
false
;
size_t
n
=
length
;
auto
*
argument
=
std
::
strchr
(
argv
[
i
],
':'
);
const
auto
*
argument
=
std
::
strchr
(
argv
[
i
],
':'
);
if
(
not
argument
)
argument
=
std
::
strchr
(
argv
[
i
],
'='
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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