temporary

C++0x rvalue references and temporaries

(I asked a variation of this question on comp.std.c++ but didn't get an answer.) Why does the call to f(arg) in this code call the const ref overload of f? void f(const std::string &); //less efficient void f(std::string &&); //more efficient void g(const char * arg) { f(arg); } My intuition says that the f(string &&) overload ...

Does a const reference prolong the life of a temporary?

Why does this: #include <string> #include <iostream> using namespace std; class Sandbox { public: Sandbox(const string& n) : member(n) {} const string& member; }; int main() { Sandbox sandbox(string("four")); cout << "The answer is: " << sandbox.member << endl; return 0; } Give output of: The answer is: Ins...

Error at creating a temporary clob from oracle in c#

Hi everyone, I want to create a temporary clob. That's my function: public static OracleLob CreateTemporaryClob(OracleConnection conn, OracleTransaction tx, string data) { OracleLob tempClob = null; byte[] bData = new System.Text.ASCIIEncoding().GetBytes(data); string cmdText = "declare a clob; begin dbms_lob.createtempora...

Pass temporary object to function that takes pointer

I tried following code : #include<iostream> #include<string> using namespace std; string f1(string s) { return s="f1 called"; } void f2(string *s) { cout<<*s<<endl; } int main() { string str; f2(&f1(str)); } But this code doesn't compile. What I think is : f1 returns by value so it creates temporary, of which I am taki...

Unable to generate temporary class in Windows 2008 R2 64 bit for C# app.

Hi, I have no clue whats going on here. My c# (VS2008) app runs fine in 32 bit OS but when i run the same in Windows 2008 R2 64bit i am getting following error: Unable to generate a temporary class (result=1). error CS0008: Unexpected error reading metadata from file 'c:\Windows\assembly\GAC_MSIL\xxxx\7.0.1001.0__5b72a65e64576834\xxxx....

rvalues and temporary objects in the FCD

It took me quite some time to understand the difference between an rvalue and a temporary object. But now the final committee draft states on page 75: An rvalue [...] is an xvalue, a temporary object or subobject thereof, or a value that is not associated with an object. I can't believe my eyes. This must be an error, right? To ...

const reference to temporary oddity

We all know that things like this are valid in c++: const T &x = T(); while: T &x = T(); is not. In a recent question the conversation lead to this rule. The OP had posted some code which clearly evokes UB. But I would have expect a modified version of it to work (This is the modified version): #include <iostream> using namespace...

Do rvalue references allow implicit conversions?

Is the following code legal? std::string&& x = "hello world"; g++ 4.5.0 compiles this code without any problems. ...

SybaseIQ cursor over atemporary table behaves as read-only even if 'for update' was specified

Hi, I'm attempting to update a temporary table using a cursor that was declared 'for update'. The update does not work: [Error Code: 7732, SQL State: 42W30] ASA Error -633: Update operation attempted on a read-only cursor The sybase iq 12.7 docs says that the cursor becomes read-only under some circumstances, like for example if aggreg...

Are sessions faster than querying the database?

So for example, the user is logging in, and the system is storing informations about them example: birth date, so is faster to get this information from the session, or to query the database for it? My idea was, that the user needs to login just once and the session is always there, but If I query the database, then if the user reloads...

Question about using string::swap() with temporaries

The following segment demonstrates my issue: (compilation error on GCC) stringstream ss; string s; ss << "Hello"; // This fails: // s.swap(ss.str()); // This works: ss.str().swap(s); My error: constSwap.cc:14: error: no matching function for call to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::swap(std::...

Why do I need std::get_temporary_buffer ?

For what purpose I should use std::get_temporary_buffer? Standard says the following: Obtains a pointer to storage sufficient to store up to n adjacent T objects. I thought that the buffer will be allocated on the stack, but that is not true. According to the C++ Standard this buffer is actually not temporary. What advantages does ...

Should I bring temporary variable declarations out of loops in C and C++?

Here is what I mean, suppose I have code like: for (int i = 0; i < 1000; i++) { char* ptr = something; /* ... use ptr here */ } It seems that char* ptr gets allocated every time in the loop, making it ineffective? Is it more effective to write this? char* ptr = something; for (int i = 0; i < 1000; i++) { /* ....

Where should Map put temporary files when running under Hadoop

Hi, I am running Hadoop 0.20.1 under SLES 10 (SUSE). My Map task takes a file and generates a few more, I then generate my results from these files. I would like to know where I should place these files, so that performance is good and there are no collisions. If Hadoop can delete the directory automatically - that would be nice. Right...

SQL "With As" Alternative Way

In a previous question, you guys helped me grab data from a different row. The statement I am using works perfectly on the MS SQL Server Managment Studio. I can run the statement without any errors and I return the data I need. However, I need to run this data on our frontend program. When I try to run my statement on this program, it ju...

Is it possible to have source code that 'times out' (becomes invalid after a certain moment)?

We are currently busy migrating from Visual Studio 2005 to Visual Studio 2010 (using unmanaged C/C++). This means that about half of our developers are already using Visual Studio 2010, while the other half is still using Visual Studio 2005. Recently, I came into a situation where a certain construction can be written in a clean way in...

mysql : temporary, filesort with 2 little tables : how can i improve my query ?

CREATE TABLE tableA ( `key` int(11) NOT NULL, `value` int(11) NOT NULL, UNIQUE KEY Akeyvalue (`key`,`value`), KEY Avalue (`value`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE tableB ( `key` int(11) NOT NULL, `value` int(11) NOT NULL, UNIQUE KEY Bkeyvalue (`key`,`value`), KEY Bvalue (`value`) ) ENGINE=InnoDB DEFAULT CHARSET=l...

Returning a c++ std::vector without a copy?

Is it possible to return a standard container from a function without making a copy? Example code: std::vector<A> MyFunc(); ... std::vector<A> b = MyFunc(); As far as I understand, this copies the return value into a new vector b. Does making the function return references or something like that allow avoiding the copy? ...

What is the best way to set up a form to get a temp var?

I am making a photo upload form. Before they begin, they have two choices. They can create a new gallery, OR they can choose from an existing gallery. I was thinking the best way to lay this out would be two have two forms. One for the create one that would take them to the create page. That's easy, and practically done. But the second...

constant references with typedef and templates in c++

I heard the temporary objects can only be assigned to constant references. But this code gives error #include <iostream.h> template<class t> t const& check(){ return t(); //return a temporary object } int main(int argc, char** argv){ const int &resCheck = check<int>(); /* fine */ typedef int& ref; const ref error = check<int...