Surchargé une fonction template avec template
Bonjour,
Je sais que ce problème a déjà été présenté dans ce forum mais les solutions proposées de fonctionne pas.
Dans mon cas j'ai un membre dans le fichier JSONSerializer.h:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #pragma once
#include "Kernel/Kernel.h"
#include "Core/String/String.h"
#include "Core/String/StringTool.h"
#include "Core/Core/Errors.h"
#include "rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"
namespace eMV
{
typedef rapidjson::UTF8<> RJ_UTF8Trait;
typedef rapidjson::GenericStringBuffer< rapidjson::UTF8<> > StringBuffer;
typedef rapidjson::Writer< StringBuffer, rapidjson::UTF8<>, rapidjson::UTF8<> > Writer;
typedef rapidjson::GenericReader< rapidjson::UTF8<>, rapidjson::UTF8<> > Reader;
typedef rapidjson::GenericDocument< rapidjson::UTF8<> > Document;
namespace Core
{
class JSONSerializer
{
public:
template < typename Type >
static
Type GetObjectFromValue( rapidjson::Value const& oValue, Type const t = Type() );
};
#include "Core/Serializer/JSONSerializer.inl"
}
} |
Dans le fichier JSONSerializer.inl:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
| template < typename Type >
inline
Type JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, Type const )
{
EMV_NOT_IMPL;
}
template <>
inline
UInt8 JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, UInt8 const )
{
return static_cast< UInt8 >( oValue.GetUint() );
}
template <>
inline
UInt16 JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, UInt16 const )
{
return static_cast< UInt16 >( oValue.GetUint() );
}
template <>
inline
UInt32 JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, UInt32 const )
{
return oValue.GetUint();
}
template <>
inline
UInt64 JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, UInt64 const )
{
return oValue.GetUint64();
}
template <>
inline
Int8 JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, Int8 const )
{
return static_cast< Int8 >( oValue.GetInt() );
}
template <>
inline
Int16 JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, Int16 const )
{
return static_cast< Int16 >( oValue.GetInt() );
}
template <>
inline
Int32 JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, Int32 const )
{
return oValue.GetInt();
}
template <>
inline
Int64 JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, Int64 const )
{
return oValue.GetInt64();
}
template <>
inline
f32 JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, f32 const )
{
return static_cast< f32 >( oValue.GetDouble() );
}
template <>
inline
f64 JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, f64 const )
{
return oValue.GetDouble();
}
template <>
inline
Core::ASCIIString JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, Core::ASCIIString const )
{
return Core::StringTool::UTF8StringToASCIIStringCopy( Core::UTF8String( oValue.GetString() ) );
}
//template <>
//Core::UTF8String JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, Core::UTF8String const )
//{
// //return Core::StringTool::UTF8StringToASCIIStringCopy( Core::UTF8String( oValue.GetString() ) );
//}
template <>
inline
Core::UTF16String JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, Core::UTF16String const )
{
return Core::StringTool::UTF8StringToUTF16StringCopy( Core::UTF8String( oValue.GetString() ) );
}
template <>
inline
Core::UTF32String JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, Core::UTF32String const )
{
return Core::StringTool::UTF8StringToUTF32StringCopy( Core::UTF8String( oValue.GetString() ) );
}
template <>
inline
Core::WideString JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, Core::WideString const )
{
return Core::StringTool::UTF8StringToWideStringCopy( Core::UTF8String( oValue.GetString() ) );
} |
Je voudrais surchargé GetObjectFromValue pour template < typename ScalarType > Math::tVector4< ScalarType >;
Donc je vais dans Vector4.h et je procède de la manière suivante dans Math/Vector4.h:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| #pragma once
#include "Math/MathConfig.h"
#include "Math/MathAPI.h"
#include "Math/Consts.h"
#include "Math/Vectorial.h"
#include "Core/Core/TypeTraits.h"
#include "Core/Stream/Stream.h"
#include "Core/Serializer/JSONSerializer.h"
#include "Core/Core/CRC32.h"
namespace eMV
{
namespace Math
{
template < typename ScalarType = Scalar >
class tVector4
{
public:
// Implementation blabla
};
// #if USE_VECTOR4_SIMD == 1 && Core::IsSame< f80, Scalar >::Value
// # error Vector4 Vectorial & Scalar f80 is not usable
// #endif
// #if Core::IsSame< f80, Scalar >::Value
// # include "Math/Vector4.hpp"
// #elif USE_VECTOR4_SIMD
// // TODO AVX & SSE f64 version with double f64 SSE Instruction OR AVX instruction
// // => TODO Only the Dot
// # include "Math/Vector4Vectorial.hpp"
// #else
// # include "Math/Vector4.hpp"
// #endif
#if Core::IsSame< f80, Scalar >::Value
# include "Math/Vector4.hpp"
#elif USE_VECTOR4_SIMD
// TODO AVX & SSE f64 version with double f64 SSE Instruction OR AVX instruction
// => TODO Only the Dot
# include "Math/Vector4Vectorial.hpp"
#else
# include "Math/Vector4.hpp"
#endif
}
namespace Core
{
template < typename ScalarType >
inline
Math::tVector4< ScalarType > JSONSerializer::GetObjectFromValue( rapidjson::Value const& oValue, Math::tVector4< ScalarType > const )
{
EMV_ASSERT( oValue.Size() == 4 );
Math::tVector4< ScalarType > vVector;
vVector.Set( static_cast< ScalarType >( oValue[ 0 ].GetDouble() ),
static_cast< ScalarType >( oValue[ 1 ].GetDouble() ),
static_cast< ScalarType >( oValue[ 2 ].GetDouble() ),
static_cast< ScalarType >( oValue[ 3 ].GetDouble() ) );
return vVector;
}
}
} |
Auriez-vous une idée de ce que j'ai mal fait ?
Merci
PS: Compilateur Intel C++ 14