我有以下功能
void f(double* arr)
{ ... }
这是在C ++ 11中调用该函数的合理方法:f({10.0, 8.0});
?感谢。
答案 0 :(得分:1)
一种可能的解决方案是在void f(double* arr){
}
void f_wrapper(std::vector<double> v){
f(v.data());
}
int main(){
f_wrapper({1.,2.,3.});
}
函数周围创建一个小包装器:
void f(const double* arr){
}
void f_wrapper(std::initializer_list<double> v){
f(v.begin());
}
int main(){
f_wrapper({1.,2.,3.});
}
或@(Kerrek SB)提到:
Public Sub CheckAndPlay(ButtonName As String)
Dim Target As Integer
Dim Position As String = Space(256)
Dim Length As String = Space(256)
Target = Microsoft.VisualBasic.Right(ButtonName, 2)
w = mciSendString("status " & Target & " position", Position, 256, 0)
w = mciSendString("status " & Target & " length", Length, 256, 0)
If Val(Position) = Val(Length) - 10 Or Val(Length) = Nothing Or Val(Position) = 0 Or Val(Position) = Nothing Then
w = mciSendString("play " & ButtonName, Nothing, 0, 0)
End If
End Sub