reference

Why GCC 5.3.0 gives warning when binding reference to “this” pointer

∥☆過路亽.° 提交于 2020-01-12 12:51:44
问题 Here is the minimal example: class A { A* const& this_ref; public: A() : this_ref(this) {} }; GCC 5.3.0 gives warning: warning: a temporary bound to 'A::this_ref' only persists until the constructor exits [-Wextra] A() : this_ref(this) {} Is this a temporary then? What the... MSVC 2015 is silent about this, and referring to class members by this_ref->member outside the constructor in my case gives expected behaviour (but might be just a case of UB, not sure). EDIT: Note this question extends

Is the address of a reference to a dereferenced pointer the same as the address of the pointer?

拈花ヽ惹草 提交于 2020-01-12 06:58:11
问题 In C++, is the address of a reference to a dereferenced pointer guaranteed to be the same as the address of the pointer? Or, written in code, is the following assertion guaranteed to always hold true? SomeType *ptr = someAddress; SomeType &ref = *ptr; assert(&ref == ptr); 回答1: Yes, that is correct and will always be true. Reference is nothing but an Alias of the type which it is referring to. It does not have a separate existence, it is always tied up to the one it is referring. 回答2: Yes,

Reference to reference in C#?

。_饼干妹妹 提交于 2020-01-12 03:29:32
问题 As we all know, C# classes object are treated as references, so what happens when you pass a reference object as a reference to a method? Say we have: public class A { ... } and then: public void F(ref A a) { ... } Does the compiler find out that a is already a reference type and keep it that way, or he creates a new reference to that object? And what if we have something like this: public void F(ref A a) { F(ref a); } In this code, besides the obvious StackOverflowException , does the

Rvalues, lvalues and formal definitions

独自空忆成欢 提交于 2020-01-12 00:53:28
问题 People are confused when they hear that in int&& x x has rvalue reference type, but x is an lvalue. Misunderstanding stems from the fact that identifiers and expressions are different things, and so are types and value categories. Moreover, types of expressions are "adjusted prior to any further analysis", and the words "rvalue" and "lvalue" can appear both in type name and in value category name. I want to clarify formal definitions. Suppose we have a function: 1 | void f(int&& x) { 2 | ...

Good reference for Roxygen? [closed]

耗尽温柔 提交于 2020-01-11 18:50:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Other than the excellent SO answer here, and the Roxygen manual and vignette, is there any particularly thorough guide to using Roxygen? 回答1: I'm working on a guide (but it's still incomplete). A more comprehensive set of vignettes have been added to the package, and were made available on CRAN as of version 4.0

How to change the loading path of references in .NET?

爱⌒轻易说出口 提交于 2020-01-11 07:31:05
问题 I want a setup like this: +- /ApplicationFolder -- App.exe -- Core.dll -- AnotherShared.dll +- /PluginsFolder -- plugin1.dll -- plugin2.dll But because plugin1.dll references to Core.dll and Shared.dll when I compile the application it drops a copy of "Copy.dll" and "Shared.dll" to plugins folder as well and if I remove them it doesn't work any more. How can I solve this problem? 回答1: When you create an AppDomain you can define a path for loading assemblies. Set AppDomainSetup.PrivateBinPath

Does this copy the vector?

↘锁芯ラ 提交于 2020-01-11 06:19:28
问题 If I have the following code, is the vector copied? std::vector<int> x = y.getTheVector(); or would it depend on whether the return type of getTheVector() is by reference? or would I just need to use: std::vector<int>& x = y.getTheVector(); or, would I need to do both? 回答1: std::vector<int> x = y.getTheVector(); always makes a copy, regardless of the return type of y.getTheVector(); . std::vector<int>& x = y.getTheVector(); would not make a copy. However, x will be valid as long as y

When does the CLR try to load a referenced assembly?

人走茶凉 提交于 2020-01-11 05:38:09
问题 I want to write a small installer app that installs a web site and creates IIS virtual directories. The app should run on Windows XP/Server 2003 (IIS 6) as well as on Vista/2008 (IIS 7). The problem is: for IIS 6 we create virt dirs by calling WMI/Metabase API, for IIS 7 there is a much better API: Microsoft.Web.Administration, but its assembly is available only on IIS 7 systems. Naive approach: ... if (OperatingSystem == old) { call metabase API... } else { call Microsoft.Web.Administration.

When does the CLR try to load a referenced assembly?

怎甘沉沦 提交于 2020-01-11 05:38:09
问题 I want to write a small installer app that installs a web site and creates IIS virtual directories. The app should run on Windows XP/Server 2003 (IIS 6) as well as on Vista/2008 (IIS 7). The problem is: for IIS 6 we create virt dirs by calling WMI/Metabase API, for IIS 7 there is a much better API: Microsoft.Web.Administration, but its assembly is available only on IIS 7 systems. Naive approach: ... if (OperatingSystem == old) { call metabase API... } else { call Microsoft.Web.Administration.

Is there ever a need to use ampersand in front of an object?

两盒软妹~` 提交于 2020-01-11 05:15:48
问题 Since objects are passed by reference by default now, is there maybe some special case when &$obj would make sense? 回答1: Objects use a different reference mechanism. &$object is more a reference of a reference. You can't really compare them both. See Objects and references: A PHP reference is an alias, which allows two different variables to write to the same value. As of PHP 5, an object variable doesn't contain the object itself as value anymore. It only contains an object identifier which