anonymous

Anonymous Namespace Ambiguity

ⅰ亾dé卋堺 提交于 2019-11-29 09:12:08
Consider the following snippet: void Foo() // 1 { } namespace { void Foo() // 2 { } } int main() { Foo(); // Ambiguous. ::Foo(); // Calls the Foo in the global namespace (Foo #1). // I'm trying to call the `Foo` that's defined in the anonymous namespace (Foo #2). } How can I refer to something inside an anonymous namespace in this case? You can't. The standard contains the following section ( §7.3.1.1 , C++03): An unnamed-namespace-definition behaves as if it were replaced by namespace unique { /* empty body */ } using namespace unique; namespace unique { namespace-body } where all occurrences

Setting anonymous type property name

牧云@^-^@ 提交于 2019-11-29 09:08:09
Let's say I have the following piece of code: string SomeConst = "OtherName"; var persons = GetPersons(); //returns list of Person var q = persons.Select(p => new { SomeConst = p.Name }); Basically I'd expect to have in q sequence of anonymous type with the property named OtherName and not SomeConst . How can I achieve such a behaviour? You can't do that. The names of the properties of an anonymous type must be known at compile time. Why exactly do you need to do that? You could achieve a similar effect by creating a sequence of dictionaries instead of anonymous objects: string SomeConst =

How to use c union nested in struct with no name

久未见 提交于 2019-11-29 08:09:26
问题 I'm working on the so called Hotspot open source project, and looking at the implementation I found a nasty nested union in struct looking like that: typedef struct RC_model_t_st { union { struct block_model_t_st *block; struct grid_model_t_st *grid; }; /* block model or grid model */ int type; thermal_config_t *config; }RC_model_t; As far as I'm aware in C/C++ that union is unaccesible. So how someone can make use of union declared in such manner and for what purpose? Thanks! 回答1: This is an

initialization of anonymous structures or unions in C1X

柔情痞子 提交于 2019-11-28 23:14:19
I have the following question: How are anonymous structures (or unions) properly initialized according to the current C1X draft ? Is this legal: struct foo { int a; struct { int i; int j; }; int b; }; struct foo f = { 1, 2, 3, 4 }; struct foo g = { 1, { 2 }, 3 }; In GCC, g.j == 0 and g.b == 3 , while in tcc g.j == 3 and g.b == 0 . The current draft says: "[...] unnamed members of objects of structure and union type do not participate in initialization. Unnamed members of structure objects have indeterminate value even after initialization.". Can this be really true? Isn't struct foo h = { 0 };

Linkage of symbols within anonymous namespace within a regular namespace

本小妞迷上赌 提交于 2019-11-28 20:42:35
In C++, putting a function or a variable in an anonymous namespace makes its linkage internal, i. e. the same as declaring it static on a file-level, but idiomatic C++. What about an anonymous namespace within a normal namespace? Does it still guarantee internal linkage? // foo.cpp void func1() { // external linkage } static void func2() { // internal linkage } namespace { void func3() { // internal linkage } } namespace ns1 { void func4() { // external linkage } namespace { void func3() { // still internal linkage? } } } legends2k C++11 (draft N3337) §3.5/4: (emphasis mine) An unnamed

How to contribute on github anonymously via Tor?

无人久伴 提交于 2019-11-28 16:58:55
I would like to contribute anonymously to projects on github. Not to cause mischief, more in the spirit of anonymous donations. The tool of choice for being anonymous online seems to be TOR, which works well for almost anything you can do in a browser. However, to contribute on github, it appears necessary to use the command line interface, or the Mac app. How can I channel my git operations in this setup through Tor? And how can I verify that this is actually what is happening? Edit: please note the difference between pseudonymous (with a fake e-mail address) and anonymous (with an IP address

Swift: Firebase: How to ensure no one can access my db except my app

我只是一个虾纸丫 提交于 2019-11-28 10:45:10
问题 My Swift iOS app only uses Firebase Anonymous Login. I am concerned about security of my Firebase Database as apparently anyone can access or delete my data (through a browser etc?). How can I secure my db so only my iOS app can access it? I would have expected that the Firebase dashboard allow to generate an API key which I can embed in my app, but that does not seem to be the case. 回答1: You need to write security rules. Anyone can see your URL, but security rules are how you dictate who has

Acegi Security: How do i add another GrantedAuthority to Authentication to anonymous user

天涯浪子 提交于 2019-11-28 09:31:11
i give users special URL with access key in it. users accessing the public page via this special url should be able to see some additional data as compared to simple anonymous user. i want to give some additional role to anonymous user based on parameters provided in request so i can do something like this in my template: <@sec.authorize ifAnyGranted="ROLE_ADMIN, ROLE_USER, ROLE_INVITED_VISITOR"> ...some additional stuff for invited user to see </@sec.authorize> currently i'm implementing Spring's OncePerRequestfilter : protected void doFilterInternal(HttpServletRequest request,

Where do I put constant strings in C++: static class members or anonymous namespaces?

隐身守侯 提交于 2019-11-28 08:57:51
I need to define some constant strings that will be used only by one class. It looks like I have three options: Embed the strings directly into locations where they are used. Define them as private static constant members of the class: //A.h class A { private: static const std::string f1; static const std::string f2; static const std::string f3; }; //A.cpp const std::string f1 = "filename1"; const std::string f2 = "filename2"; const std::string f3 = "filename3"; //strings are used in this file Define them in an anonymous namespace in the cpp file: //A.cpp namespace { const std::string f1 =

TProc<TObject> to TNotifyEvent

倖福魔咒の 提交于 2019-11-28 07:34:50
Further to this post whose accepted answer remains very cryptic: @Button1.OnClick := pPointer(Cardinal(pPointer( procedure (sender: tObject) begin ((sender as TButton).Owner as TForm).Caption := 'Freedom to anonymous methods!' end )^ ) + $0C)^; I wonder wether it is possible to devise a simplest and elegant way akin to: Button.OnClick := AnonProc2NotifyEvent ( procedure (Sender: TObject) begin ((Sender as TButton).Owner as TForm).Caption := 'Freedom to anonymous methods!' end ); so as to attain the same purpose and where AnonProc2NotifyEvent is a method of the owner of Button with the