我正在使用很棒的fmt C++ 库来更优雅地格式化字符串。
我想将一个非变量参数列表传递给fmt::format. 它可能是一个std::vector, 或std::string或其他任何形式,但它始终与格式字符串匹配。
所以fmt::format工作原理如下:
std::string message = fmt::format("The answer is {} so don't {}", "42", "PANIC!");
Run Code Online (Sandbox Code Playgroud)
但我想要的是这样的:
std::vector<std::string> arr;
arr.push_back("42");
arr.push_back("PANIC!");
std::string message = fmt::format("The answer is {} so don't {}", arr);
Run Code Online (Sandbox Code Playgroud)
有没有办法/解决方法来做到这一点?
我的Makefile有点问题.我想make改变有关工作目录的命令.我在测试当前目标的目录($(*D))的规则中添加了条件指令.
问题是make总是进入我的测试的第二个分支,即使我的文件在mySpecialDirectory中并且echo确实打印了"mySpecialDirectory".
.c.o .cpp.o .cc.o:
ifeq ($(*D),mySpecialDirectory)
@echo "I'm in mySpecialDirectory! \o/"
$(CC) $(DEBUG_FLAGS) $(MYSPECIALFLAGS) -c $< -o $@
else
@echo "Failed! I'm in $(*D)"
$(CC) $(DEBUG_FLAGS) $(NOTTHATSPECIALFLAGS) -c $< -o $@
endif
Run Code Online (Sandbox Code Playgroud) 在我的 Iphone 应用程序中,我在 viewDidLoad() 方法中使用了以下 3 个图像的动画代码,并使用左变换加载此 ViewController。但是这些 imageView 并没有显示在视图上。
NSArray *newArray = [[NSArray alloc]initWithObjects:[UIImage imageNamed:@"search1.png"],
[UIImage imageNamed:@"search2.png"],
[UIImage imageNamed:@"seach3.png"],
nil];
UIImageView *imageView = [UIImageView alloc];
[imageView initWithFrame:CGRectMake(240, 60, 60, 30)];
imageView.animationImages = newArray;
imageView.animationDuration = 0.25;
imageView.animationRepeatCount = 3;
[self.view addSubview:imageView];
Run Code Online (Sandbox Code Playgroud) animation ×1
c++ ×1
conditional ×1
fmt ×1
formatting ×1
ipad ×1
iphone ×1
makefile ×1
objective-c ×1
variables ×1
variadic ×1