Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
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
Hurstel
CGoGN
Commits
b82bd2ed
Commit
b82bd2ed
authored
Mar 21, 2013
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resolved pb of compil
parent
6f6cb139
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
38 deletions
+38
-38
include/Utils/convertType.h
include/Utils/convertType.h
+38
-38
No files found.
include/Utils/convertType.h
View file @
b82bd2ed
...
...
@@ -35,91 +35,91 @@ namespace Utils {
/**
* Create a ref to a type from a ref from another type
* No copy only casting. No need to used IN template parameter
* No copy only casting. No need to used
T_
IN template parameter
* @param vec input ref
* @ return a ref on same object with OUT type
* @ return a ref on same object with
T_
OUT type
*/
template
<
typename
OUT
,
typename
IN
>
inline
OUT
&
convertRef
(
IN
&
vec
)
template
<
typename
T_OUT
,
typename
T_
IN
>
inline
T_OUT
&
convertRef
(
T_
IN
&
vec
)
{
assert
(
sizeof
(
IN
)
==
sizeof
(
OUT
)
||
"incompatible size cast"
);
return
*
(
reinterpret_cast
<
OUT
*>
(
&
vec
));
assert
(
sizeof
(
T_IN
)
==
sizeof
(
T_
OUT
)
||
"incompatible size cast"
);
return
*
(
reinterpret_cast
<
T_
OUT
*>
(
&
vec
));
}
/**
* Create a const ref to a type from a const ref from another type
* No copy only casting. No need to used IN template parameter
* No copy only casting. No need to used
T_
IN template parameter
* @param vec input ref
* @ return a ref on same object with OUT type
* @ return a ref on same object with
T_
OUT type
*/
template
<
typename
OUT
,
typename
IN
>
inline
const
OUT
&
convertRef
(
const
IN
&
vec
)
template
<
typename
T_OUT
,
typename
T_
IN
>
inline
const
T_OUT
&
convertRef
(
const
T_
IN
&
vec
)
{
assert
(
sizeof
(
IN
)
==
sizeof
(
OUT
)
||
"incompatible size cast"
);
return
*
(
reinterpret_cast
<
const
OUT
*>
(
&
vec
));
assert
(
sizeof
(
T_IN
)
==
sizeof
(
T_
OUT
)
||
"incompatible size cast"
);
return
*
(
reinterpret_cast
<
const
T_
OUT
*>
(
&
vec
));
}
/**
* Create a ptr of a type from a ptr of another type
* Just a reinterpret cast in fact
* @param vec input ptr
* @return a ptr on same object with OUT type
* @return a ptr on same object with
T_
OUT type
*/
template
<
typename
OUT
,
typename
IN
>
inline
OUT
*
convertPtr
(
IN
*
vec
)
template
<
typename
T_OUT
,
typename
T_
IN
>
inline
T_OUT
*
convertPtr
(
T_
IN
*
vec
)
{
assert
(
sizeof
(
IN
)
==
sizeof
(
OUT
)
||
"incompatible size cast"
);
return
reinterpret_cast
<
OUT
*>
(
vec
);
assert
(
sizeof
(
T_IN
)
==
sizeof
(
T_
OUT
)
||
"incompatible size cast"
);
return
reinterpret_cast
<
T_
OUT
*>
(
vec
);
}
/**
* Create a const ptr of a type from a const ptr of another type
* Just a reinterpret cast in fact
* @param vec input ptr
* @return a ptr on same object with OUT type
* @return a ptr on same object with
T_
OUT type
*/
template
<
typename
OUT
,
typename
IN
>
inline
const
OUT
*
convertPtr
(
const
IN
*
vec
)
template
<
typename
T_OUT
,
typename
T_
IN
>
inline
const
T_OUT
*
convertPtr
(
const
T_
IN
*
vec
)
{
assert
(
sizeof
(
IN
)
==
sizeof
(
OUT
)
||
"incompatible size cast"
);
return
reinterpret_cast
<
const
OUT
*>
(
vec
);
assert
(
sizeof
(
T_IN
)
==
sizeof
(
T_
OUT
)
||
"incompatible size cast"
);
return
reinterpret_cast
<
const
T_
OUT
*>
(
vec
);
}
template
<
typename
OUT
,
typename
IN
>
inline
std
::
vector
<
OUT
>&
convertVector
(
std
::
vector
<
IN
>&
vec
)
template
<
typename
T_OUT
,
typename
T_
IN
>
inline
std
::
vector
<
T_OUT
>&
convertVector
(
std
::
vector
<
T_
IN
>&
vec
)
{
assert
(
sizeof
(
IN
)
==
sizeof
(
OUT
)
||
"incompatible size cast"
);
return
*
(
reinterpret_cast
<
std
::
vector
<
OUT
>*
>
(
&
vec
));
assert
(
sizeof
(
T_IN
)
==
sizeof
(
T_
OUT
)
||
"incompatible size cast"
);
return
*
(
reinterpret_cast
<
std
::
vector
<
T_
OUT
>*
>
(
&
vec
));
}
template
<
typename
OUT
,
typename
IN
>
inline
const
std
::
vector
<
OUT
>&
convertVector
(
const
std
::
vector
<
IN
>&
vec
)
template
<
typename
T_OUT
,
typename
T_
IN
>
inline
const
std
::
vector
<
T_OUT
>&
convertVector
(
const
std
::
vector
<
T_
IN
>&
vec
)
{
assert
(
sizeof
(
IN
)
==
sizeof
(
OUT
)
||
"incompatible size cast"
);
return
*
(
reinterpret_cast
<
const
std
::
vector
<
OUT
>*
>
(
&
vec
));
assert
(
sizeof
(
T_IN
)
==
sizeof
(
T_
OUT
)
||
"incompatible size cast"
);
return
*
(
reinterpret_cast
<
const
std
::
vector
<
T_
OUT
>*
>
(
&
vec
));
}
template
<
typename
OUT
,
typename
IN
>
inline
const
std
::
list
<
OUT
>&
convertList
(
const
std
::
list
<
IN
>&
vec
)
template
<
typename
T_OUT
,
typename
T_
IN
>
inline
const
std
::
list
<
T_OUT
>&
convertList
(
const
std
::
list
<
T_
IN
>&
vec
)
{
assert
(
sizeof
(
IN
)
==
sizeof
(
OUT
)
||
"incompatible size cast"
);
return
*
(
reinterpret_cast
<
const
std
::
list
<
OUT
>*
>
(
&
vec
));
assert
(
sizeof
(
T_IN
)
==
sizeof
(
T_
OUT
)
||
"incompatible size cast"
);
return
*
(
reinterpret_cast
<
const
std
::
list
<
T_
OUT
>*
>
(
&
vec
));
}
template
<
typename
OUT
,
typename
IN
>
inline
std
::
list
<
OUT
>&
convertList
(
std
::
list
<
IN
>&
vec
)
template
<
typename
T_OUT
,
typename
T_
IN
>
inline
std
::
list
<
T_OUT
>&
convertList
(
std
::
list
<
T_
IN
>&
vec
)
{
assert
(
sizeof
(
IN
)
==
sizeof
(
OUT
)
||
"incompatible size cast"
);
return
*
(
reinterpret_cast
<
std
::
list
<
OUT
>*
>
(
&
vec
));
assert
(
sizeof
(
T_IN
)
==
sizeof
(
T_
OUT
)
||
"incompatible size cast"
);
return
*
(
reinterpret_cast
<
std
::
list
<
T_
OUT
>*
>
(
&
vec
));
}
...
...
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