Now, I'm just studying about smart_ptr (unique_ptr / shared_ptr). And I wrote test code like this for checking unique_ptr can be used as argument.

typedef struct __T_TEST
{
char cT1;
char cT2;
} T_TEST;

int main(...)
{
...
char szB[2] = {0x61, 0x62};

auto pTest = std::make_unique&lt;T_TEST&gt;();
std::memcpy(pTest, szB, 2);
printf("T1 = [%02x]\n", pTest-&gt;cT1);
printf("T2 = [%02x]\n", pTest-&gt;cT2);

return 0;
}


And then, I added one function using unique_ptr as parameter like this.

int TestPrint(std::unique_ptr&lt;T_TEST&gt; p_pData)
{
    printf("T1 in TestPrint Func = [%02x]\n", p_pData-&gt;cT1);
    printf("T2 in TestPrint Func = [%02x]\n", p_pData-&gt;cT2);
    return 0;
}


I'm just calling that function in main function after printf. But it doesn't work.

printf("T1 = [%02x]\n", pTest-&gt;cT1);
printf("T2 = [%02x]\n", pTest-&gt;cT2);

TestPrint(pTest);  &lt;- Can't pass the pTest!

return 0;
}


In this case, I can't pass the pTest. Why not? I think pTest is std::unique_ptr and p_pData is std::unique_ptr in TestPrint function. So it's the same type!! But I can't. I want to know why it doesn't work.

Of course, it can work after changing the function to std::unique_ptr&lt;T_TEST&gt;&amp; p_pData. But I don't understand why I can't pass the parameter despite of same data type.


Question: Splicing tiny wire inside broken mouse cable
Answer: I disagree with Chris in that you don't just want to shorten the cable.  It's not the length of cable I'm worried about, but that tiny connector you don't want to replicate.  The connector and the wires immediately coming out of it look to be intact.  Replacing that will be a major pain in the butt, so I'd go to reasonable length to preserve that piece.

Since that piece is now short, you'll have to make a splice.  Just realize up front you're not going to make a splice in such small cable that is anything like the size of the cable.  The splice will be big, fat, and ugly in comparison.  It looks like it can be made to serve as the strain relief too, so that helps a little.

To splice such tiny wires, see if you can sortof stick the stranded ends into each other.  That may take some persuasion under a magnifying light, and then some weighty objects on your bench to hold them in place while you solder.  This won't be easy, but it should be doable.  If that just isn't practical, give up and bend each wire into a U and hook the two U ends together, flatten them together with a needlenose, then solder.

Once you have the connections made, wrap each one individually in a small piece of electrical tape, then wrap the whole bundle in electrical tape so that is looks like one fat section of cable.  Like I said, big, fat, and ugly, but it should work.  All that tape will act like a strain relief, so that section shouldn't break again.