我有一个带有签名void add_world_triangle(float position[3]);
我是否可以使用类似于render_state.add_world_triangle({-0.5, -0.5, -1});
?
答案 0 :(得分:3)
我建议使用std::array
:
#include <array>
void add_world_triangle(std::array<float, 3> position) {
}
int main() {
add_world_triangle({-0.5, -0.5, -1});
}
答案 1 :(得分:2)
[{"products":[{"productId":"1","name":"Fluffy Eggs"},{"productId":"1","name":"Crispy Bacon"}]},
{"reviews":[{"reviewId":"1","title":"These are some nice eggs.","productId":"1","description":"Eggs that are just the right temp and extremely fluffy."},
{"reviewId":"2","title":"mmm, bacon","productId":"2","description":"it's pretty crispy. Maybe a little too crispy."}]},
{"ratings":[{"ratingId":"1","reviewId":"1","rating":"5"},
{"ratingId":"2","reviewId":"1","rating":"4"},
{"ratingId":"3","reviewId":"2","rating":"1"},
{"ratingId":"4","reviewId":"1","rating":"5"},
{"ratingId":"5","reviewId":"1","rating":"5"},
{"ratingId":"6","reviewId":"2","rating":"5"},
{"ratingId":"7","reviewId":"2","rating":"4"},
{"ratingId":"8","reviewId":"1","rating":"5"}]}]
如果您不要求引用,则数组类型会衰减为指针,显然无法从void f(int const(&a)[3]);
void g(){ f({1,2,3}); }
构建指针。