reference

Pass self reference to contained object's function

情到浓时终转凉″ 提交于 2019-12-22 11:31:55
问题 I'm trying to grok Rust's ownership model. I'm trying to pass a reference to a containing object when calling a function on a struct. Here's my struct: pub struct Player {} impl Player { pub fn receive(self, app: &App) { } } As you can see, receive expects a reference to an App object. pub struct App { pub player: Player, } impl App { pub fn sender(self) { // how to call player.test() and pass self as a reference? self.player.receive(&self); } } The above code gives me "use of partially moved

How do I return a list as an array reference in Perl?

此生再无相见时 提交于 2019-12-22 11:28:06
问题 Hey. In Python I can do this: def fnuh(): a = "foo" b = "bar" return a,b Can I return a list in a similarly elegant way in perl, especially when the return type of the subroutine should be a reference to an array? I know I can do sub fnuh { my $a = "foo"; my $b = "bar"; my $return = []; push (@{$return}, $a); push (@{$return}, $b); return $return; } But I bet there is a better way to do that in Perl. Do you know it? 回答1: Sure, just slap a \ in front of the list to return a reference. Or make

Referencing .NET dll when compiliation(with mono)

南笙酒味 提交于 2019-12-22 10:45:52
问题 I asked a question to install F# powerpack and use it here. error FS0078: Unable to find the file 'FSharp.PowerPack.Linq.dll' in any of /Library/Frameworks/Mono.framework/Versions/2.10.2/lib/mono/2.0 /Users/smcho/Desktop/fs/powerpack /Users/smcho/smcho/bin/FSharp-2.0.0.0/bin When I run this command fsc linq.fs /r:FSharp.PowerPack.Linq.dll , I got this error message with mono. It seems that with /r: , the mono F# compiler seems to find the dll in /Library/Frameworks/Mono.framework/Versions/2

function call ambiguity with pointer, reference and constant reference parameter

懵懂的女人 提交于 2019-12-22 10:45:49
问题 What I am trying to do is, allow a pointer, reference or constant reference to be passed with the setter function: class A{ std::string * p; std::string st; public: A():p(0) {} A& setS(const std::string& s){ std::cout<<"called with const std::string&\n"; st = s; p = &st; return *this; } A& setS(std::string& s) { std::cout<<"called with std::string&\n"; p = &s; return *this; } A& setS(std::string* s) { std::cout<<"called with std::string*\n"; p = s; return *this; } }; int main(){ std::string s

Web App Compiling Error - ASP.NET Reference

安稳与你 提交于 2019-12-22 09:50:05
问题 My current web app works fine locally and on live, what i am currently playing around with is compiling my Web App with the Visual Studio Option "Add Web Deployment Project" so all the code behind is compiled into DLL's. There's is one particular build error i can not get rid off Error 50 The type or namespace name 'usercontrols_calendarcell_ascx' does not exist in the namespace 'ASP' (are you missing an assembly reference?) c:\page.ascx.cs 30 1 test_deploy And the actual line of code is as

How can I assign the result of a subroutine call to array references in Perl?

谁都会走 提交于 2019-12-22 09:48:31
问题 Is it possible to assign an array variable to an array reference instead of to scalar variables? Instead of this: ($a, $b) = some_sub(\@d, \@e); I want something like this: (@x, @y) = some_sub(\@x1, \@y1); If so, how can I dereference it.where as in case of former, @$xxxx does for us. Thanks. 回答1: You can do it in 2 steps (3 lines actually): my ($x_ref, $y_ref) = some_sub(\@x1, \@y1); my @x = @{ $x_ref }; my @y = @{ $y_ref }; The question is - wouldn't it be simpler to simply ditch the direct

Bind const std::pair<T, U>& to value of std::pair<const T, U>

北城以北 提交于 2019-12-22 09:41:40
问题 The below code snippet compiles with a very important warning. #include <map> #include <vector> template <typename iterator> const std::pair<int, float> &foo(iterator it) { return *it; } int main() { std::vector<std::pair<int, float>> vector; std::map<int, float> map; vector.push_back(std::make_pair(0, 0.0)); map.insert(std::make_pair(0, 0.0)); const std::pair<int, float> &r1 = foo(vector.begin()); const std::pair<int, float> &r2 = foo(map.begin()); if (r1 != r2) { return 1; } return 0; }

Angular 6 - Refused to apply style from '…' because its MIME type ('text/html') is not a supported stylesheet

霸气de小男生 提交于 2019-12-22 08:48:08
问题 Trying to upgrade to Angular 6 and got the below error when I referred the below in index.html: Refused to apply style from 'https://localhost:44394/~/assets/primengcss/themes/omega//theme.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. 回答1: Found the answer (at least worked for me), after some digging around: Looks like inAngular 6 we need to include any external CSS (like bootstrap, fontawesome, Primeng etc.,) to the

Web Site in solution where “Rebuild Solution” compile succeeds cannot launch debugger

淺唱寂寞╮ 提交于 2019-12-22 08:47:08
问题 I have a solution that includes a Web Site (created using the web site template not the web app project template - converting isn't an option, btw). When I rebuild all, the compile succeeds, but strangely displays 3 errors, all of which are "Could not get dependencies for project reference 'PROJNAME'". When I try to launch the debugger, I get the "There were build errors." dialogue. Two questions: If I choose the 'Yes' option in the debug error dialogue to run the last successful build, will

VB6: Name conflicts with existing module, project, or object library

不想你离开。 提交于 2019-12-22 07:00:39
问题 Opening a VB6 Project, I get errors like: Errors during load. Refer to xyz.LOG I open the log file and see these errors: Line 42: Class Threed.SSPanel of control XYZ was not a loaded control class. In this case I can see the problem is due to the Sheridan 3D Controls: C:\WINDOWS\system32\THREED32.OCX I thought the project was missing a component so, VB6 > Project > Components > tick the Sheridan 3D Controls and got this error: ---------------------- Microsoft Visual Basic --------------------