« first day (496 days earlier)      last day (2353 days later) » 

nwp
12:53 AM
@sehe Looks loungy.
 
1:52 AM
Hey guys, I'm reading through effective C++, and wanted to play around w/ some template specialization on ctors myself
for some reason the last fn won't work, although it seems like the right soln on stack overflow
what should be the correct syntax, or can you not explicitly define a function specialization that's the same as a function overloading signature?
 
2:40 AM
@OneRaynyDay At least if memory serves, you can only explicitly specialize a member function when you also explicitly specialize the class. Syntax would look like this: coliru.stacked-crooked.com/a/094677b1b320bb51
Note that the specialization is not separately declared, only defined.
 
 
2 hours later…
4:18 AM
@JerryCoffin Ahhh... that is very ugly... Thanks though! appreciate it :)
 
4:36 AM
@OneRaynyDay Surely.
 
 
16 hours later…
8:12 PM
Hey Fellas I am trying to find Odd occurrences in an array say
{3,3,3,1,2}
3 -> odd number of time so
3 should be the output

I have implemented this by using XOR (on bits)
not sure why it gives me garbage value
#include<iostream>
using namespace std;
int main ()
{
int arr[10];
int input,res=0;
cout<<"size of array\n";
cin>>input;
for(int j=0;j<input;j++)
{
cin>>arr[j];
}
int sizeofarray=0;
sizeofarray = sizeof(arr)/sizeof(arr[0]);
for (int i=0;i<sizeofarray;i++)
{
 res = res ^ arr[i];
 cout<<"number is \n"<<res;
}
//cout<<"number odd times\n"<<res;
return 0;
}
 
8:50 PM
If I delete an unordered_map that has vectors inside of it, do the vectors get deleted also or I have to manually starting from the inermost container of a container ultin I hit the map (basically the root)?
 
9:30 PM
Hello! I'm very new to c++ and I'm doing an exercise that asks me to implement a very simple memory pool using this as a start:

template <class T>
class MemoryPool
{
public:
void *allocate(size_t);
void release(void*);

private:
std::vector<size_t> freed_;
size_t next_;
T pool_[1000];
};
I'm don't know how to start... could You guys give me some hint?
Asked wrong place... sorry
 
3 messages moved from Lounge<C++>
@AnnaK. of course they do get deleted
The word you are looking is "destructed". Value semantics in C++ imply every value with automatic storage duration is always deterministically destructed. Same goes for owned elements in dynamically allocating containers
The only way you can lose is when you use raw pointers or members without applying Rule-Of-Zero (or Rule-Of-Three or Rule-Of-Five as history would require)
@JoãoPaulo you need how the usage patterns will be
 
9:49 PM
You mean this?
MemoryPool pool;
T* p = new (&pool) A();
operator delete(p, &pool);
 
operator delete?
That's weird.
 
yeah... I'm really lost on it :D
operator delete in-place
 
@JoãoPaulo TIL there's placement delete. Items 13,14 and 15,16 strongly suggest no one should be calling that though.
Interesting nonetheless
This could be worth a Stack Overflow search or post
 
Search didn't helped that much... I was afraid about been abusive to make it a post, but I think I'll do it...
 
Since c++11 it seems like this should be exploited:
> Thus, replacing the throwing single object deallocation functions (1,3) is sufficient to handle all deallocations.
@JoãoPaulo Just be sure to add context (like that usage pattern, but perhaps descriptive names for the arguments could be in order)
 
10:01 PM
Ok! Thank you!
 

« first day (496 days earlier)      last day (2353 days later) »