#include <iostream>
#include <string>
#include <array>
class C {
private:
std::string a;
std::string b;
std::string c;
public:
C(std::string a_, std::string b_, std::string c_) : a{a_},b{b_},c{c_} {}
~C(){};
C(const C&) =delete;
C(const C&&) =delete;
const C& operator=(const C&) =delete;
const C& operator=(const C&&) =delete;
};
std::array<C,2> array = {C("","",""),C("","","")};
int main()
{}
Run Code Online (Sandbox Code Playgroud)
这将无法编译(带有NDK和clang的Android Studio)带有"调用已删除的c构造函数"错误.我知道我可以使用a std::vector和emplace_back()直接在容器内构造一个元素,但在我的代码中我只想使用固定大小的容器和不可复制/可移动的对象进行优化.我可能在这里缺少基本的,但是没有一种方法来初始化,std::array而不必先构建单个元素然后将它们复制到那里?
我需要成对地将一个自定义func应用于STL容器- >即:
// if c => {a,b,c,d,e,f,g}; // a,b,c,.. are just aliases for some object
my_algorithm(c.begin(),c.end(),[](auto a, auto b){ a + b }); // c++14
Run Code Online (Sandbox Code Playgroud)
应该解决这样的事情:
temp1 = a + b;
temp2 = c + d;
temp3 = e + f;
temp4 = temp1 + temp2;
temp5 = temp3 + g;
result = temp4 + temp5;
Run Code Online (Sandbox Code Playgroud)
(我确信这种算法有一个合适的名称,但我不知道这可能是什么)
我试过std::accumulate,我不确定它的实现是否由标准定义,但在我的情况下和我的编译器似乎解决了这个问题(我认为这称为成对求和,对吧?):
temp1 = a + b;
temp2 = temp1 + c;
temp3 = temp2 + d;
// …Run Code Online (Sandbox Code Playgroud) 如果flyspell-mode启用并且我尝试用希腊文写作,我会在大多数时候尝试在某个字符上键入重音时出错:
<268632064> is undefined
Run Code Online (Sandbox Code Playgroud)
键入带重音的字符的正常顺序是首先输入',然后输入适当的元音.相反,每当flyspell-mode打开时,'和先前键入的字符被解释为<268632064>对可能的任何触发错误的调用,因此,后续字符显示为没有重音.
所以,
什么时候flyspell-mode关闭,? ' ?- >??
当flyspell-mode在,? ? ?- > ??和一个<268632064> is undefined错误
注意:我在2015年中期的macbook pro上使用GNU Emacs 25.3.1(x86_64-apple-darwin16.7.0,NS appkit-1504.83版本10.12.6(Build 16G29)).
我有这段代码:
auto time_point_a = std::chrono::high_resolution_clock::now();
while (true) {
auto time_point_b = std::chrono::high_resolution_clock::now();
auto counter_ms = std::chrono::duration_cast<std::chromo::milliseconds(time_point_b - time_point_a);
// more code
std::cont << counter_ms.count() << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
为counter_ms.count()保证始终返回一个有效的价值?有没有count()抛出的机会?如果counter_ms超过其底层整数类型的大小会发生什么(我估计它long long)?我的程序将连续运行几天,我需要知道如果/什么时候counter_msTOO很大会发生什么.
我正试图将自己从组_developer和procmod中删除,我意外地使用以下命令添加它:
sudo dseditgroup -o edit -a marinos -t user _developer
sudo dseditgroup -o edit -a marinos -t user procmod
Run Code Online (Sandbox Code Playgroud)
当id我得到这个:
uid=501(marinos) gid=20(staff) groups=20(staff),401(com.apple.sharepoint.group.1),9(procmod),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),204(_developer),502(access_bpf),33(_appstore),100(_lpoperator),395(com.apple.access_ftp),398(com.apple.access_screensharing),399(com.apple.access_ssh)
Run Code Online (Sandbox Code Playgroud)
删除我试过
sudo dscl . -delete /Groups/_developer GroupMembership marinos
Run Code Online (Sandbox Code Playgroud)
我收到这个错误
<main> attribute status: eDSAttributeNotFound
<dscl_cmd> DS Error: -14134 (eDSAttributeNotFound)
Run Code Online (Sandbox Code Playgroud)
而这个sudo dscl.-delete/Groups/procmod GroupMembership marinos导致没有错误但不会将我从组中删除 - id返回与以前完全相同的组.
我也尝试过:
sudo dseditgroup -o edit -u marinos -d procomod user procmod
Run Code Online (Sandbox Code Playgroud)
我明白了
Group not found.
Run Code Online (Sandbox Code Playgroud)
还有这个:
sudo dseditgroup -o edit -u marinos -d procmod user procmod
Run Code Online (Sandbox Code Playgroud)
这导致没有错误,但也没有影响.. id仍然表明我是所有这些组的成员..
请帮忙......我很绝望
我在数值数据上有一个Struct点,带有一个returnNext()方法,该方法每次调用时都会在stdout中返回AND post.我还有一系列使用这种方法的单元测试:在那些测试中我想要压缩所有Data的std :: cout,这样我只检查返回值的有效性,而不会使屏幕膨胀消息.例如
struct Data {
Data(int n): datum{n} {};
int datum;
int returnNext() {
std::cout << datum << " returned" << std::endl;
return datum;
}
}
// main.cpp
int main() {
Data d{100};
d.returnNext(); // I want this to print at the screen
return 0;
}
// test.cpp
int main() {
TEST( ... ) {
Data d{100};
ASSERT_THAT(d.returnNext(), 100); // I want just to check the output, not to check
}
std::cout << "some message" << std::endl; // …Run Code Online (Sandbox Code Playgroud) 使用防护、RAII 和 try/catch 块来确保线程在所有情况下最终都会加入是一种常见的做法。但是,对于要分离的线程又如何呢?
void aFunction() {
std::thread t {someOtherFunction}; // someOtherFunction may throw!!!
t.detach;
}
Run Code Online (Sandbox Code Playgroud)
我是否应该使用某种异常处理机制来确保t即使在发生异常的情况下也能正确分离,或者这并不重要?
我正在使用这个简单的MyMarker类
class MyMarker: GMSMarker {
var id: UInt32 = 0
}
Run Code Online (Sandbox Code Playgroud)
这样我的标记也可以包含额外的数字标记.当用户点击我的标记时,我打电话给a segue打开一个新的场景,其中的内容是动态的并且是相对于MyMarkers的绘制的id.我想做的事情如下:
func mapView(mapView: GMSMapView, didTapMarker marker: MyMarker) -> Bool {
some_global_variable = marker.id;
performSegueWithIdentifier("segue", sender: nil)
return true
}
Run Code Online (Sandbox Code Playgroud)
问题当然是GMSMapViewDelegate期望标记是类型的 GMSMarker.
我怎样才能实现我追求的行为?
我正在尝试Polyline根据我在此处找到的代码(第三个答案)创建一个点。我想出了这个:
// route
let path = GMSMutablePath()
// populate path with coordinates here
// ...
let route = GMSPolyline(path: path)
route.strokeWidth = 3.0
let styles = [GMSStrokeStyle.solidColor(UIColor(red: 0.945, green: 0.392, blue: 0.278, alpha: 1.0)), GMSStrokeStyle.solidColor(UIColor.clearColor())]
let lengths = [10,10]
route.spans = GMSStyleSpans(route.path!, styles, lengths, kGMSLengthRhumb);
route.map = m_map_view
Run Code Online (Sandbox Code Playgroud)
unresolved identifier但是,我得到一个错误,因为kGMSLengthRhumb在我的系统中没有将其标识为某个有效常量。我正在使用Swift 2.0。
kGMSLengthRhumb我在哪里或应该放在哪里?
我通过算法在 OpensCad 中导入 stl 文件,我希望包含的模型始终位于中心,也就是说,以某种方式计算它们的中心应该是什么,然后使用平移将其带到 x、y、z 轴所在的点相交。那可能吗?
在Mac Os X中使用alt带有其他键的键会产生一系列特殊符号.例如,alt-'结果æ,alt-3结果£等.但是,当使用emacs时,我不能再以这种方式输入这些特殊符号,因为alt现在映射到meta.有没有办法映射alt到其他一些关键组合?或者也许只使用左侧alt作为元,并且正常行为与其他应用程序中的正常行为一样?
我想叫ViewController"s中的成员函数AppDelegateS" applicationWillResignActive功能.不确定最好的方法是什么.我试过这样做:
let landmark = LandmarkViewController()
landmark.test()
Run Code Online (Sandbox Code Playgroud)
但它似乎不合适.我实际上是在创建控制器的新实例,而不是使用已经存在的实例.
我有三项活动:
主要活动:
public void start_main_map(View view) {
Intent intent = new Intent(this, com.example.MainMap.class);
startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud)
主地图:
protected GoogleApiClient mGoogleApiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "onCreate");
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
protected void onStart() {
Log.i(TAG, "onStart");
mGoogleApiClient.connect();
super.onStart();
}
@Override
protected void onStop() {
Log.i(TAG, "onStop");
mGoogleApiClient.disconnect();
super.onStop();
}
@Override
protected void onPause() {
Log.i(TAG, "onPause");
super.onPause();
}
@Override
public void onResume() {
Log.i(TAG, "onResume");
super.onResume();
}
@Override
public void onMapReady(GoogleMap googleMap) {
Log.i(TAG, "onMapReady"); …Run Code Online (Sandbox Code Playgroud)