Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Cazier
CGoGN
Commits
b82bd2ed
Commit
b82bd2ed
authored
Mar 21, 2013
by
Sylvain Thery
Browse files
resolved pb of compil
parent
6f6cb139
Changes
1
Hide whitespace changes
Inline
Side-by-side
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
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