我会直接去MCVE:
#include <sstream>
struct A
{
inline static std::stringstream ss;
};
GCC 7.2和7.1 refuse to compile出现以下错误:
error: no matching function for call to 'std::__cxx11::basic_stringstream::basic_stringstream()' inline static std::stringstream ss; ^~ In file included from blah:1:0: /opt/compiler-explorer/gcc-7.2.0/include/c++/7.2.0/sstream:723:7: note: candidate: std::__cxx11::basic_stringstream::basic_stringstream(std::__cxx11::basic_stringstream&&) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator] basic_stringstream(basic_stringstream&& __rhs) ^~~~~~~~~~~~~~~~~~ /opt/compiler-explorer/gcc-7.2.0/include/c++/7.2.0/sstream:723:7: note: candidate expects 1 argument, 0 provided
您可以在没有任何标记的情况下重现该标记,也可以使用-std=c++17
重现。
Clang 5.0编译它没有任何问题。
其他类(例如std::string
)可以inline static
没有问题。
使其成为非内联静态可以消除错误。
不是GCC的错误,还是我错过了什么?
答案 0 :(得分:4)
错误。减少到:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.view addObserver:self forKeyPath:@"bounds" options:NSKeyValueObservingOptionNew context:nil];
if (!_viewFirstAppeared) {
_viewFirstAppeared = YES;
void(^applyViews)(void) = ^{
[self.centerController.view removeFromSuperview];
[self.centerView addSubview:self.centerController.view];
[self doForControllers:^(UIViewController* controller, IIViewDeckSide side) {
[controller.view removeFromSuperview];
[self.referenceView insertSubview:controller.view belowSubview:self.slidingControllerView];
}];
[self setSlidingFrameForOffset:_offset forOrientation:_offsetOrientation];
self.slidingControllerView.hidden = NO;
self.centerView.frame = self.centerViewBounds;
self.centerController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.centerController.view.frame = self.centerView.bounds;
[self doForControllers:^(UIViewController* controller, IIViewDeckSide side) {
controller.view.frame = self.sideViewBounds;
controller.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}];
[self applyShadowToSlidingViewAnimated:NO];
};
if ([self setSlidingAndReferenceViews]) {
applyViews();
applyViews = nil;
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.001 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void){
if (applyViews) applyViews();
[self setSlidingFrameForOffset:_offset forOrientation:_offsetOrientation];
[self hideAppropriateSideViews];
});
[self addPanners];
if ([self isSideClosed:IIViewDeckLeftSide] && [self isSideClosed:IIViewDeckRightSide] && [self isSideClosed:IIViewDeckTopSide] && [self isSideClosed:IIViewDeckBottomSide])
[self centerViewVisible];
else
[self centerViewHidden];
}
else if (_willAppearShouldArrangeViewsAfterRotation != UIDeviceOrientationUnknown) {
for (NSString* key in [self.view.layer animationKeys]) {
[self.view.layer animationForKey:key].duration);
}
[self willRotateToInterfaceOrientation:self.interfaceOrientation duration:0];
[self willAnimateRotationToInterfaceOrientation:self.interfaceOrientation duration:0];
[self didRotateFromInterfaceOrientation:_willAppearShouldArrangeViewsAfterRotation];
}
[self.centerController viewWillAppear:animated];
[self transitionAppearanceFrom:0 to:1 animated:animated];
_viewAppeared = 1;
}
GCC初始化处理代码中的某些地方错误地将其视为复制初始化上下文,忽略了显式默认构造函数。