问题列表 - 第44357页

_Exit如何在C++程序中运行?

C99提供了_Exit功能,"立即"退出,但它确实可以关闭文件描述符.Unix/POSIX通过强制关闭所有fd而不刷新(并提供同义词_exit)来扩展此行为.

static当从C++程序调用时,这些函数是否会调用对象的析构函数?C++标准是否有任何保证_Exit

(受这个问题的启发;我突然想知道典型的情况会发生什么fork- exec- _exitC++中的习语.)

c c++ unix destructor exit

12
推荐指数
2
解决办法
2705
查看次数

WPF:在其父面板中获取Child的真正"逻辑"位置

我的WPF问题系列中的另一个问题:)

我正在创建Decorator将用于装饰Panels的自定义(或者它可以是行为,没有区别).

Decorator涉及那个Panel(Children属性)中的元素Panel.它将一些RenderTransform内容附加到这些元素上.现在我需要一个Panel相对于它Panel自身的元素('child' )的位置.换句话说,如果Panels坐标空间中有一些子元素,我需要一个位置.换句话说,我想要通过when调用方法的ArrangeOverride方法指定的偏移量.PanelArrangeChildren

这似乎很容易.但我无法找到始终获得正确坐标的方法.

这段代码

VisualTreeHelper.GetOffset(child)
Run Code Online (Sandbox Code Playgroud)

当面板在里面时ScrollView它不起作用- 它Panel作为坐标空间的原点 - 而不是真正的最顶端和最左边的角落 - 位于最顶部,最左边的可见角落Panel.

代码

Point position = child.TransformToAncestor(panel).Transform(new Point(0,0));
Run Code Online (Sandbox Code Playgroud)

当某些渲染变换在子元素上已经激活时,它将不起作用Panel.它将返回子元素的变换图像的位置(通过渲染变换).渲染位置.

同样的问题是这个问题:

Point panelPosition = panel.PointToScreen(new Point(0, 0));
Point childPosition = child.PointToScreen(new Point(0, 0));
Point position = new Point(childPosition.X - panelPosition.X, childsPosition.Y - panelPosition.Y);
Run Code Online (Sandbox Code Playgroud)

所以这就是我所尝试的但是它没有用.我有两个关于这个主题的类似问题,它们正在努力简化问题,所以我得到了一些上面的建议.现在我以完全复杂的方式介绍了这个问题,我希望得到正确的建议.

如果不清楚,请留下评论.谢谢

.net c# wpf custom-controls wpf-controls

5
推荐指数
1
解决办法
3172
查看次数

以编程方式更改NSTextField中的文本?

我习惯在Cocoa-touch中这样做,所以我认为它会很简单.我已经尝试过了:

field.text = [nsstring stringwithformat:@"%i", number];
[field setText:@"%i", number];
Run Code Online (Sandbox Code Playgroud)

和setString,都无济于事.

macos cocoa nsstring nstextfield

11
推荐指数
1
解决办法
2万
查看次数

Html.TextBoxFor格式和css类

下面的两行代码工作正常,但我想将它们组合起来.我的意思是:我想在第一个代码行中使用@class.我怎样才能做到这一点?

<%: Html.TextBoxFor(model => model.Product.Price, String.Format("{0:f}", Model.Product.Price))%>

<%: Html.TextBoxFor(model => model.Product.Name, new { @class = "textBox150" })%>
Run Code Online (Sandbox Code Playgroud)

谢谢,

菲利普

html.textbox asp.net-mvc-2

29
推荐指数
2
解决办法
6万
查看次数

从java中的另一个字符串中删除字符串

可以说我有这个单词列表:

 String[] stopWords = new String[]{"i","a","and","about","an","are","as","at","be","by","com","for","from","how","in","is","it","not","of","on","or","that","the","this","to","was","what","when","where","who","will","with","the","www"};
Run Code Online (Sandbox Code Playgroud)

比我有文字

 String text = "I would like to do a nice novel about nature AND people"
Run Code Online (Sandbox Code Playgroud)

是否有匹配stopWords的方法并在忽略大小写的情况下删除它们; 像这样在某个地方?:

 String noStopWordsText = remove(text, stopWords);
Run Code Online (Sandbox Code Playgroud)

结果:

 " would like do nice novel nature people"
Run Code Online (Sandbox Code Playgroud)

如果你知道正则表达式工作得很好但我真的更喜欢像公共解决方案更具有性能导向的东西.

顺便说一句,现在我正在使用这种缺乏适当的不敏感案例处理的公共方法:

 private static final String[] stopWords = new String[]{"i", "a", "and", "about", "an", "are", "as", "at", "be", "by", "com", "for", "from", "how", "in", "is", "it", "not", "of", "on", "or", "that", "the", "this", "to", "was", "what", "when", "where", "who", "will", "with", "the", …
Run Code Online (Sandbox Code Playgroud)

java string

6
推荐指数
3
解决办法
1万
查看次数

Haskell:从后面访问列表

今天我开始学习Haskell.我是函数式语言的新手,我很喜欢Haskell.

然而,我有一个关于它的设计的问题,这让我烦恼:从我到目前为止所理解的看起来像访问列表后面的元素看起来要复杂得多,因为访问元素到前面(类似于xs:x哪里xs::[a]x::a似乎不可能).

(根据我的理解)可以将列表附加到另一个(xs++[a]),但它在运行时会花费更多(它需要遍历整个列表)并且它不能用于模式匹配.

为什么Haskell缺少这样的操作?

haskell list append

2
推荐指数
2
解决办法
1705
查看次数

获取当前用户的GUID?

我想在用户提交帖子时从用户检索的信息中添加用户的GUID.我怎样才能获得GUID?

我正在使用ASP.NET MVC应用程序附带的默认身份验证系统.

asp.net asp.net-mvc

12
推荐指数
1
解决办法
2万
查看次数

如何"应用"无参数函数的结果

这有效:

List(3, 1, 2).sorted apply 1
res1: Int = 2
Run Code Online (Sandbox Code Playgroud)

这有效:

var x = List(3, 1, 2).sorted
x: List[Int] = List(1, 2, 3)
x(1)
res2: Int = 2
Run Code Online (Sandbox Code Playgroud)

但这不是:

List(3, 1, 2).sorted (1)

error: type mismatch;
 found   : Int(1)
 required: Ordering[?]
       List(3, 1, 2).sorted (1)
                             ^
Run Code Online (Sandbox Code Playgroud)

甚至括号也不能解析解析器到我想要的东西:

(List(3, 1, 2).sorted)(1)

error: type mismatch;
 found   : Int(1)
 required: Ordering[?]
       (List(3, 1, 2).sorted)(1)
Run Code Online (Sandbox Code Playgroud)

这似乎是一种自然的表达.我究竟做错了什么?

scala

8
推荐指数
2
解决办法
290
查看次数

C++ - 如何避免此标题出现两次?

在:http://www.learncpp.com/cpp-tutorial/110-a-first-look-at-the-preprocessor/

在Header guards下,有一些代码片段:

add.h:

#include "mymath.h"
int add(int x, int y);
Run Code Online (Sandbox Code Playgroud)

subtract.h:

#include "mymath.h"
int subtract(int x, int y);
Run Code Online (Sandbox Code Playgroud)

main.cpp中:

#include "add.h"
#include "subtract.h"
Run Code Online (Sandbox Code Playgroud)

我怎样才能避免#include "mymath.h"出现两次main.cpp

谢谢.

c++ header include-guards

0
推荐指数
1
解决办法
3124
查看次数

使用Mono.Cecil查找类型层次结构程序集

我试图实现一个接收类型的方法,并返回包含其基类型的所有程序集.

例如:
Class A是基类型(类A属于程序集c:\ A.dll)
B继承自A(类B属于程序集c:\ B.dll)
C继承自B(类C属于程序集c:\ c.dll)

public IEnumerable<string> GetAssembliesFromInheritance(string assembly, 
                                                        string type)
{
    // If the method recieves type C from assembly c:\C.dll
    // it should return { "c:\A.dll", "c:\B.dll", "c:\C.dll" }
}
Run Code Online (Sandbox Code Playgroud)

我的主要问题是AssemblyDefinition来自Mono.Cecil不包含任何属性,如Location.

如何给出装配位置AssemblyDefinition

c# reflection assemblies mono.cecil

5
推荐指数
1
解决办法
1601
查看次数