reference

Checking for the existence a reference/type at compile time in .NET

Deadly 提交于 2020-01-04 14:04:33
问题 I've recently found the need to check at compile-time whether either: a) a certain assembly reference exists and can be successfully resolved, or b) a certain class (whose fully qualified name is known) is defined. These two situations are equivalent for my purposes, so being able to check for one of them would be good enough. Is there any way to do this in .NET/C#? Preprocessor directives initially struck me as something that might help, but it seems it doesn't have the necessary capability.

How do I check if System::Collections:ArrayList is empty / nullptr / null?

丶灬走出姿态 提交于 2020-01-04 13:42:04
问题 I'd like to know how in C++/CLI it is possible to check whether an ArrayList is existent. System::Collections::ArrayList %queue_tx I tried if ( nullptr != queue_tx ) { queue_tx.Add(msg); } but that didn't work. I'm passing queue_tx as a parameter to a function and there's supposed to be the possibility of this parameter not being set (or being set to nullptr ). The compiler throws '!=' : no conversion from 'System::Collections::ArrayList' to 'nullptr' . How do I do this? 回答1: % defines a

IOCP multithreaded server and reference counted class

倖福魔咒の 提交于 2020-01-04 09:04:45
问题 I work on IOCP Server (Overlapped I/O , 4 threads, CreateIoCompletionPort, GetQueuedCompletionStatus, WSASend etc). And my goal is to send single reference counted buffer too all connected sockets.(I followed Len Holgate's suggestion from this post WSAsend to all connected socket in multithreaded iocp server) . After sending buffer to all connected clients it should be deleted. this is class with buffer to be send class refbuf { private: int m_nLength; int m_wsk; char *m_pnData; // buffer to

.NET Multiple Class Library in One Library

一个人想着一个人 提交于 2020-01-04 06:04:46
问题 I am working in VS2008. I have a custom class library (CL1) which references another custom class library (CL2). This ends up having CL1 and CL2 in my release folder. Now the consumer of CL1 needs to include two dll's in the project which I think is not appropriate. I have strong feeling that there must be a way to achieve a single DLL solution. Is there a recommended (guideline-d) way of achieving this. Merging CL1 and CL2 is not an option because CL2 is more common and referenced in

Different object and reference

℡╲_俬逩灬. 提交于 2020-01-04 05:47:09
问题 I was trying to learn Java from Tutorials Point. So, may be this question would be so basic. But I am really stuck here. And I don't know what to google to get it resolved. Please have a look at this program. class Animal{ public void move(){ System.out.println("Animals can move"); } } class Dog extends Animal{ public void move(){ System.out.println("Dogs can walk and run"); } } public class TestDog{ public static void main(String args[]){ Animal a = new Animal(); Animal b = new Dog(); a.move

Passing a reference to a C++ constructor

夙愿已清 提交于 2020-01-04 05:26:12
问题 I have this code: #include <iostream> using namespace std; struct X { int a = 1; }; struct Y { X &_x; Y(X &x) : _x(x) {} }; // intentionally typoed version of Y, without the reference in the constructor struct Z { X &_x; Z(X x) : _x(x) {} }; int main() { X x; Y y(x); Z z(x); cout << "x: " << &x << endl; cout << "y.x: " << &y._x << endl; cout << "z.x: " << &z._x << endl; } I keep finding myself forgetting the & in the constructor of my classes of this format. This outputs the following: x:

C++ standard: dereferencing NULL pointer to get a reference? [duplicate]

怎甘沉沦 提交于 2020-01-04 05:21:37
问题 This question already has answers here : Is null reference possible? (4 answers) Closed 6 months ago . I'm wondering about what the C++ standard says about code like this: int* ptr = NULL; int& ref = *ptr; int* ptr2 = &ref; In practice the result is that ptr2 is NULL but I'm wondering, is this just an implementation detail or is this well defined in the standard? Under different circumstances a dereferencing of a NULL pointer should result in a crash but here I'm dereferencing it to get a

i am getting an error Argument 2 may not be passed with ref keyword while using ado.net

前提是你 提交于 2020-01-04 04:38:08
问题 int? t = 0; cmd.Parameters.AddWithValue("@Res", ref t); I get an error in the second line: argument 2 may not be passed with ref keyword. 回答1: You can only pass an argument by reference with ref if the parameter is a ref parameter as well. AddWithValue doesn't have any ref parameters, so you can't use it that way. Note that you have to specify ref when calling a method if a parameter has the ref modifier. So: public void WithRef(ref int x) {} public void WithoutRef(int x) {} ... int y = 0; //

Qt QSS Tutorials

杀马特。学长 韩版系。学妹 提交于 2020-01-04 04:37:08
问题 Are there any good Qt QSS tutorials or is there some place where I can see examples of styling widgets? I'd like some complete reference if is there available somewhere. I couldn't find anything but small tutorials on how to style a button or some tabs. Thanks! 回答1: Qt Style Sheets Topics: Overview The Style Sheet Syntax Qt Designer Integration Customizing Qt Widgets Using Style Sheets Qt Style Sheets Reference Qt Style Sheets Examples 来源: https://stackoverflow.com/questions/11165177/qt-qss

Does a PHP per-function (or per-task) performance / benchmark reference exist?

雨燕双飞 提交于 2020-01-04 02:54:10
问题 I'm running my own (albeit, basic) benchmarks in a linux-based sandbox. However, I'd love to find a per-function or per-task performance / benchmark reference or utility for comparison. Does this exist? Of course I've done my own fair diligence / searching and have so far come up empty handed.. (I'm primarily interested in information relevant to PHP 5.3) Thanks very much! :) 回答1: Googling brings up the two I know best: The PHP Benchmark PHP Benchmarks they don't do function benchmarks,