Symantec Interview Question
Senior Software Development EngineersTeam: MTS
Country: India
Interview Type: Phone Interview
The only way is to use goold old C-cast:
#include <type_traits>
template<typename TargetType, typename SourceType>
TargetType const_cast_artificial(const SourceType& in) {
static_assert(std::is_same<std::remove_cv<SourceType>::type,
std::remove_cv<TargetType>::type>::value,
"Invalid const cast");
return (TargetType)in;
}
The only way is to use goold old C-cast:
#include <type_traits>
template<typename TargetType, typename SourceType>
TargetType const_cast_artificial(const SourceType& in) {
static_assert(std::is_same<std::remove_cv<SourceType>::type,
std::remove_cv<TargetType>::type>::value,
"Invalid const cast");
return (TargetType)in;
}
The only way is to use goold old C-cast:
#include <type_traits>
template<typename TargetType, typename SourceType>
TargetType const_cast_artificial(const SourceType& in) {
static_assert(std::is_same<std::remove_cv<SourceType>::type,
std::remove_cv<TargetType>::type>::value,
"Invalid const cast");
return (TargetType)in;
}
- celicom May 04, 2016