Ubuntu 13.04 64 ビットで DMD64 D コンパイラ v2.063.2 を使用しています。
私は以下のようにクラスを書きました:
class FixedList(T){
// list
private T[] list;
// number of items
private size_t numberOfItems;
// capacity
private size_t capacity;
// mutex
private Mutex listMutex;
// get capacity
@property public size_t Capacity(){ return capacity; }
@property public shared size_t Capacity(){ return capacity; }
// constructor
public this( size_t capacity ){
// initialise
numberOfItems = 0;
this.capacity = capacity;
writeln("Cons Normal");
}
// constructor
public shared this( size_t capacity ){
// initialise
numberOfItems = 0;
this.capacity = capacity;
// create mutex
listMutex = cast(shared)(new Mutex());
writeln("Cons Shared");
}
}
クラスはこのように書かれていますが、メイン関数では、そのコードを書きました:
auto list1 = new shared FixedList!int( 128 );
auto list2 = new FixedList!int( 128 );
これで出力すると、エラーはまったくなく、出力は次のようになります。
Cons Shared
Cons Normal
次にwriteln
、コードから両方の行を削除します。コードを再コンパイルすると、次のようなエラー メッセージが表示されるようになります。
src/webapp.d(61): Error: constructor lists.FixedList!(int).FixedList.this called with argument types:
((int) shared)
matches both:
lists.d(28): lists.FixedList!(int).FixedList.this(ulong capacity)
and:
lists.d(37): lists.FixedList!(int).FixedList.this(ulong capacity)
src/app.d(61): Error: no constructor for FixedList
src/app.d(62): Error: constructor lists.FixedList!(int).FixedList.this called with argument types:
((int))
matches both:
lists.d(28): lists.FixedList!(int).FixedList.this(ulong capacity)
and:
lists.d(37): lists.FixedList!(int).FixedList.this(ulong capacity)
src/app.d(62): Error: no constructor for FixedList
make: *** [all] Error 1
基本的にwriteln
関数はエラーを防止しています。実際writeln
には多くの場所で防止されていますが、なぜこれが起こっているのかわかりません.
32ビット用のフラグを付けてコードをコンパイルしようとしましたm32
が、それでも同じです。私は何か間違ったことをしていますか、それともこれはバグですか?