namespaces

What does “using namespace” do exactly?

核能气质少年 提交于 2021-02-16 05:49:12
问题 The following C++ test code does not link (gcc 4.9.2, binutils 2.25). The error is In function 'main': undefined reference to 'X::test' . 01: #include <string> 02: #include <iostream> 03: 04: namespace X 05: { 06: extern std::string test; 07: }; 08: 09: using namespace X; 10: std::string test = "Test"; 11: 12: int main() 13: { 14: std::cout << X::test << std::endl; 15: } Because of line 09, I was expecting line 10 to define the X::test variable declared on line 06. I believe that instead an

What does “using namespace” do exactly?

╄→гoц情女王★ 提交于 2021-02-16 05:48:05
问题 The following C++ test code does not link (gcc 4.9.2, binutils 2.25). The error is In function 'main': undefined reference to 'X::test' . 01: #include <string> 02: #include <iostream> 03: 04: namespace X 05: { 06: extern std::string test; 07: }; 08: 09: using namespace X; 10: std::string test = "Test"; 11: 12: int main() 13: { 14: std::cout << X::test << std::endl; 15: } Because of line 09, I was expecting line 10 to define the X::test variable declared on line 06. I believe that instead an

Using namespace in laravel view

走远了吗. 提交于 2021-02-11 06:20:18
问题 How to use namespace in laravel View? I mean I have three different folders admin , frontend and client in app/views folder. If I want to load a partial template lets say from admin section views/admin/partials/flush.blade.php in views/admin/account/profile.blade.php I have to include it like: @include('admin/partials/flush') instead I want to just use @include('partials/flush') How can i do that? 回答1: You can extend blade and write a function that fits your needs. Like this: Blade::extend

Dynamically change namespace in C#

末鹿安然 提交于 2021-02-10 12:12:14
问题 I want to do something like this. If DEBUG is defined then the namespace is Test, or the namespace is TestB. See the sample code bellow. Can I do that or you have better ideas to achieve this? Thanks in advance! # if DEBUG [SomekindofAttribute(Namespace = "Test")] #endif namespace TestB { public class Program {} } 回答1: You can do this: #if DEBUG namespace TestB #else namespace Test #endif { public class Program { } } Though this looks like a very bad idea. Everything using Program would have

R S3 method not exported from namespace

自闭症网瘾萝莉.ら 提交于 2021-02-09 07:29:29
问题 Why do I have this error message : > vegan::reorder.hclust Error: 'reorder.hclust' is not an exported object from 'namespace:vegan' While this S3 method is well available. For example if I type help(reorder.hclust, package = "vegan") I obtain the intended help page and vegan:::reorder.hclust displays the source code of the function on the console... Also the NAMESPACE file of my vegan installation contains S3method(reorder, hclust) . I would like to use this function in another package were I

R S3 method not exported from namespace

☆樱花仙子☆ 提交于 2021-02-09 07:24:47
问题 Why do I have this error message : > vegan::reorder.hclust Error: 'reorder.hclust' is not an exported object from 'namespace:vegan' While this S3 method is well available. For example if I type help(reorder.hclust, package = "vegan") I obtain the intended help page and vegan:::reorder.hclust displays the source code of the function on the console... Also the NAMESPACE file of my vegan installation contains S3method(reorder, hclust) . I would like to use this function in another package were I

VBScript, MSXML and Namespaces

こ雲淡風輕ζ 提交于 2021-02-08 15:32:01
问题 Given the following XML: <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <GetMsisdnResponse xmlns="http://my.domain.com/"> <GetMsisdnResult> <RedirectUrl>http://my.domain.com/cw/DoIdentification.do2?sessionid=71de6551fc13e6625194</RedirectUrl> </GetMsisdnResult> </GetMsisdnResponse> </soap:Body> </soap:Envelope> I am trying to access the

Label references for associations

两盒软妹~` 提交于 2021-02-07 18:11:11
问题 Rails provides label references for associations in fixtures like this: ### in pirates.yml reginald: name: Reginald the Pirate monkey: george ### in monkeys.yml george: name: George the Monkey pirate: reginald This works great for not-namedspaced models, but I'm using namespaces, and so Rails gets confused, and want to insert the labels instead of the label references. Any workaround or fix known? 回答1: Fixtures.identify seems to be the only solution, not really beautiful but better than ids.

Label references for associations

北城余情 提交于 2021-02-07 18:06:40
问题 Rails provides label references for associations in fixtures like this: ### in pirates.yml reginald: name: Reginald the Pirate monkey: george ### in monkeys.yml george: name: George the Monkey pirate: reginald This works great for not-namedspaced models, but I'm using namespaces, and so Rails gets confused, and want to insert the labels instead of the label references. Any workaround or fix known? 回答1: Fixtures.identify seems to be the only solution, not really beautiful but better than ids.

Name resolution of functions inside templates instantiated with qualified types

三世轮回 提交于 2021-02-07 12:52:24
问题 Consider the following C++ code example: namespace n { struct A {}; } struct B {}; void foo(int) {} template<typename T> void quux() { foo(T()); } void foo(n::A) {} void foo(B) {} int main() { quux<n::A>(); // Error (but works if you comment out the foo(int) declaration) quux<B>(); // Works return 0; } As indicated in the comment, the template instantiation quux<n::A>() causes a compiler error (on GCC 4.6.3): foo.cpp: In function ‘void quux() [with T = n::A]’: foo.cpp:22:16: instantiated from