scope-resolution

vim does not find and replace simple phrase that is clearly present

喜夏-厌秋 提交于 2019-12-02 19:54:57
I have a simple vim problem that Google hasn't managed to help me with. Any thoughts are appreciated. I do the following search and replace: :s/numnodes/numnodes1/g On a file containing the following text: numprocs=0 numnodes=0 I get E486: Pattern not found The position of the green square which indicates where I'd start typing is clearly above the pattern. I tried searching for other short phrases not involving regex, which are also present, which also fail. A simple /numnodes highlights matches as expected. Does anyone have any idea what might be the matter with vim? mmccomb Try :%s

Scope-resolution operator :: versus member-access operator . in C#

别等时光非礼了梦想. 提交于 2019-12-01 17:39:01
In C#, what's the difference between A::B and A.B ? The only difference I've noticed is that only :: can be used with global , but other than that, what's the difference? Why do they both exist? with :: you can do things like... extern alias X; extern alias Y; class Test { X::N.A a; X::N.B b1; Y::N.B b2; Y::N.C c; } and there are times when . is ambiguous so :: is needed. here's the example from the C# language spec namespace N { public class A {} public class B {} } namespace N { using A = System.IO; class X { A.Stream s1; // Error, A is ambiguous A::Stream s2; // Ok } } http://download

What does ::new mean?

↘锁芯ラ 提交于 2019-12-01 05:25:40
When examining the MS directX 11 DXUT example, the following code appeared: template<typename TYPE> HRESULT CGrowableArray <TYPE>::SetSize( int nNewMaxSize ) { int nOldSize = m_nSize; if( nOldSize > nNewMaxSize ) { assert( m_pData ); if( m_pData ) { // Removing elements. Call dtor. for( int i = nNewMaxSize; i < nOldSize; ++i ) m_pData[i].~TYPE(); } } // Adjust buffer. Note that there's no need to check for error // since if it happens, nOldSize == nNewMaxSize will be true.) HRESULT hr = SetSizeInternal( nNewMaxSize ); if( nOldSize < nNewMaxSize ) { assert( m_pData ); if( m_pData ) { // Adding

What does ::new mean?

本秂侑毒 提交于 2019-12-01 02:24:22
问题 When examining the MS directX 11 DXUT example, the following code appeared: template<typename TYPE> HRESULT CGrowableArray <TYPE>::SetSize( int nNewMaxSize ) { int nOldSize = m_nSize; if( nOldSize > nNewMaxSize ) { assert( m_pData ); if( m_pData ) { // Removing elements. Call dtor. for( int i = nNewMaxSize; i < nOldSize; ++i ) m_pData[i].~TYPE(); } } // Adjust buffer. Note that there's no need to check for error // since if it happens, nOldSize == nNewMaxSize will be true.) HRESULT hr =

struct with member function as parameter

馋奶兔 提交于 2019-12-01 01:31:02
I am a beginner in C++ and stack exchange. I am working on an Interface class that gets keyboard input and checks to see whether it is correct through looping through an array of structs which contains strings to compare to and strings to output depending if it is equal to the compare string or not. If the input is correct, it will print the string within the struct and a function within the structure is called and does some action. interface.hpp #include <string> class Input_Interface { struct command_output { std::string command; std::string success_string; std::string failure_string; void

C++0x decltype and the scope resolution operator

烂漫一生 提交于 2019-11-29 03:36:42
With a class such as Foo: struct Foo { static const int i = 9; }; I find that GCC 4.5 will reject the following Foo f; int x = decltype(f)::i; It will work if I use an intermediate typedef, such as: typedef decltype(f) ftype; int x = ftype::i; but I prefer to keep the namespace clean. I thought precedence may be an issue, so I've also tried parentheses, but no luck. Is it impossible as presented, or is there a piece of syntax that can help me? It is valid C++0x to say decltype(f)::i . GCC just doesn't support it yet. You can work it around with an identity template template<typename T> struct

What does the “::” mean in “::tolower”?

。_饼干妹妹 提交于 2019-11-29 01:58:02
I've seen code like this: std::string str = "wHatEver"; std::transform(str.begin(), str.end(), str.begin(), ::tolower); And I have a question: what does mean :: before tolower? and std::tolower not works, but ::tolower works OK Means that it is explicitly using the tolower in the global namespace (which is presumably the stdc lib one). Example: void foo() { // This is your global foo } namespace bar { void foo() { // This is bar's foo } } using namespace bar; void test() { foo(); // Ambiguous - which one is it? ::foo(); // This is the global foo() } James Kanze As to why the :: is necessary:

In C++, what is the scope resolution (“order of precedence”) for shadowed variable names?

半世苍凉 提交于 2019-11-29 01:25:36
In C++, what is the scope resolution ("order of precedence") for shadowed variable names? I can't seem to find a concise answer online. For example: #include <iostream> int shadowed = 1; struct Foo { Foo() : shadowed(2) {} void bar(int shadowed = 3) { std::cout << shadowed << std::endl; // What does this output? { int shadowed = 4; std::cout << shadowed << std::endl; // What does this output? } } int shadowed; }; int main() { Foo().bar(); } I can't think of any other scopes where a variable might conflict. Please let me know if I missed one. What is the order of priority for all four shadow

C++0x decltype and the scope resolution operator

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 17:54:01
问题 With a class such as Foo: struct Foo { static const int i = 9; }; I find that GCC 4.5 will reject the following Foo f; int x = decltype(f)::i; It will work if I use an intermediate typedef, such as: typedef decltype(f) ftype; int x = ftype::i; but I prefer to keep the namespace clean. I thought precedence may be an issue, so I've also tried parentheses, but no luck. Is it impossible as presented, or is there a piece of syntax that can help me? 回答1: It is valid C++0x to say decltype(f)::i .

In C++, what is the scope resolution (“order of precedence”) for shadowed variable names?

不羁岁月 提交于 2019-11-27 16:09:23
问题 In C++, what is the scope resolution ("order of precedence") for shadowed variable names? I can't seem to find a concise answer online. For example: #include <iostream> int shadowed = 1; struct Foo { Foo() : shadowed(2) {} void bar(int shadowed = 3) { std::cout << shadowed << std::endl; // What does this output? { int shadowed = 4; std::cout << shadowed << std::endl; // What does this output? } } int shadowed; }; int main() { Foo().bar(); } I can't think of any other scopes where a variable