namespaces

What Standard Calls are Actually Macros

不打扰是莪最后的温柔 提交于 2019-12-30 12:25:24
问题 I asked a question here about assert which is implemented in the standard as a macro, not a function. This had caused me an issue because the way that assert appears to be a function in the way it takes a parameter: assert(true) Thus I tried to use it as: std::assert(true) and of course being a macro that didn't work. My question is this: Are there any other macros provided by the standard library which would appear as functions that take parameters? 回答1: If we look at [headers] paragraphs 5

Elegant way to prevent namespace poisoning in C++

那年仲夏 提交于 2019-12-30 11:28:06
问题 Let's assume, Bob has wrapped his library into the namespace "bob", and Alice is going to make the whole namespace visible inside her own function by a single "using namespace bob", instead of "using bob::XYZ" for every single item: // This file is written by Alice: #include <iostream> // She uses Bobs library: #include "bob.hpp" int main(void) { // Import Bobs library and use it: using namespace bob; unsigned short value = 50000; bob::dump_as_signed(value); // Should not be possible without

can a python function call a global function with the same name?

萝らか妹 提交于 2019-12-30 09:53:42
问题 Can I call a global function from a function that has the same name? For example: def sorted(services): return {sorted}(services, key=lambda s: s.sortkey()) By {sorted} I mean the global sorted function. Is there a way to do this? I then want to call my function with the module name: service.sorted(services) I want to use the same name, because it does the same thing as the global function, except that it adds a default argument. 回答1: Python's name-resolution scheme which sometimes is

Using “::” instead of “module …” for Ruby namespacing

百般思念 提交于 2019-12-30 08:14:30
问题 In Ruby, is there a difference between writing class Foo::Bar and module Foo; class Bar for namespacing? If so, what? 回答1: If you use class Foo::Bar , but the Foo module hasn't been defined yet, an exception will be raised, whereas the module Foo; class Bar method will define Foo if it hasn't been defined yet. Also, with the block format, you could define multiple classes within: module Foo class Bar; end class Baz; end end 回答2: Also notice this curious bit of Ruby-ismness: FOO = 123 module

C++ name space confusion - std:: vs :: vs no prefix on a call to tolower?

99封情书 提交于 2019-12-30 06:51:21
问题 Why is this? transform(theWord.begin(), theWord.end(), theWord.begin(), std::tolower); - does not work transform(theWord.begin(), theWord.end(), theWord.begin(), tolower); - does not work but transform(theWord.begin(), theWord.end(), theWord.begin(), ::tolower); - does work theWord is a string. I am using namespace std; Why does it work with the prefix :: and not the with the std:: or with nothing? thanks for your help. 回答1: using namespace std; instructs the compiler to search for

Rails: form_for namespaced resource

北城余情 提交于 2019-12-30 04:01:10
问题 I want to set up the CRUD for users, available just for administrators of my web application. So in routes.rb: namespace :admin do resources :user end which means this: admin_user_index GET /admin/user(.:format) admin/user#index POST /admin/user(.:format) admin/user#create new_admin_user GET /admin/user/new(.:format) admin/user#new edit_admin_user GET /admin/user/:id/edit(.:format) admin/user#edit admin_user GET /admin/user/:id(.:format) admin/user#show PUT /admin/user/:id(.:format) admin

C#: How to convert a Website project to a Web Project

拥有回忆 提交于 2019-12-30 03:25:08
问题 UPDATE: All of these problems was for converting a Website application to a Web Project in Visual Studio. Once I dug in and I found the solution, as I marked as answer below. Basically, if you are wanting to upgrade/move your Website project to a Web Project, you will run into a number of errors. The short how-to is in the answer below. Thank you all for comments and help. Old question and title is below: How to wrap namespace xx {} to all class files? How would you wrap namespace to all

Restrict access to .NET assembly?

依然范特西╮ 提交于 2019-12-30 01:23:04
问题 Is there a way to have a .NET assembly accessible for only authorized sources? I mean I want to have a DLL that contains components, but I don't want anyone to be able to use these components but the other DLLs EXEs in my solution. I do want them to be in separated DLLs though. Restriction on namespace might also be a good idea if this feature exists out there. Is there a way? 回答1: You can create internal classes. And the give your specified assemblies to access these classes by using

How to create PHP SOAP request with multiple namespaces

寵の児 提交于 2019-12-29 08:39:06
问题 I'm attempting to get a shipping quote from an SOAP service. I've been able to successfully create authentication headers and query the SOAP service with basic requests that require no body parameters. I'm able to create the proper structure for the request but the namespace values are not showing up in the request output. Example code: $client = new SoapClient("http://demo.smc3.com/AdminManager/services/RateWareXL?wsdl", array('trace' => TRUE)); $headerParams = array('ns1:licenseKey' => $key

Eclipse-CDT: Use Namespace in automatic generated include-guards

末鹿安然 提交于 2019-12-29 08:27:32
问题 Is it possible (and how) to add the namespace in the name of the automatic generated include guards in Eclipse CDT, when creating a new class using the .hpp/.cpp templates? For me Eclipse generates a new class with a namespace nicely, but the include guards do not contain the namespace, so if the same header file exists twice in two different directories, only one can be included. In my case the name of the namespace, the Eclipse project name and the name of the source directory are all the