いい言葉が思い浮かばないので、そういうタイトルにしました。
template
私はd struct
s が a の中にあり、これらの s の非メンバー (フリー関数) であるオーバーロードされた演算子namespace
が定義されているこの DLL を持っています。struct
「VectorX.h」
#ifdef SPECS
#define SPECS __declspec(dllimport)
#else
#define SPECS __declspec(dllexport)
#endif // SPECS
namespace swc
{
template <typename T>
struct Vec3 : Vec2<T>
{
Vec3();
Vec3(T value); //*1
Vec3& operator = (const T scalar); //*1
...
Vec3& operator += (const Vec3<T> &v);
Vec3& operator += (const T scalar);
//*1 w/c of this two are used when I do `Vec3<T> v = 0.0f;` ??
};
//What attribute should I use to make this works?
//It's compiling but it cause undefined reference when I use it.
//Or I have many ambiguous calls here(?)
template<typename T>
/* SPECS, static, extern */ Vec3<T> const operator * (const Vec3<T> &v, const T scalar);
template<typename T>
/* SPECS, static, extern */ Vec3<T> const operator * (const T scalar, const Vec3<T> &v);
typedef Vec3<float> Vec3f;
}
それから私はそれを使用しようとしました
「test.cpp」
#include <iostream>
#include "../../VectorX/vectorx.h"
using namespace swc;
Vec3f CalculateBezierPoint(float t, const Vec3f &p0, const Vec3f &p1, const Vec3f &p2, const Vec3f &p3);
int main()
{
...
}
Vec3f CalculateBezierPoint(float t, const Vec3f &p0, const Vec3f &p1, const Vec3f &p2, const Vec3f &p3)
{
float u = 1 - t;
float tt = t * t;
float uu = u * u;
float uuu = uu * u;
float ttt = tt * t;
Vec3f p = uuu; //is it the operator '=' or the constructor Vec3f(T value)?
//**this is where the compiler starts complaining about undefined references.**
p += 3 * uu * t * p1;
p += 3 * u * tt * p2;
p += ttt * p3;
return p0;
}
これは機能しますp += 3 * 2 * 1;
が、これは機能しませんp += 3 * 2 * 1 * p1;
エラーの原因は、私が作ったフリー関数のオーバーロードされた演算子の宣言によるものだと思いますnamespace
が、他に何をすべきかわかりません。