c++ - const_string lib issue -
I am trying to Lib which is not feeling bad, but it violates access (atomic_account, operator ++ ( )) At runtime. Test code:
#include & lt; Boost / const_string / const_string.hpp & gt; #include & lt; Boost / const_string / concatenation.hpp & gt; Typedef boost :: const_string & lt; Wchar_t & gt; Wcstring; Class Test {Private: Constwcstring & S 1; Const wcstring & s2; Public: Test (): S1 (L ""), S2 (L "") {} Conak wcstring and GetS1 () {Returns S1; } Const wcstring and GetS2 () {Return s2; }}; Test t; Int _tmain (int argc, _TCHAR * argv []) {// test t; Wcstring t1 = t.GetS1 (); // crashes here wcstring t2 = t.GetS2 (); Return 0; } It crashes only when T is global, if I take the announcement in main (), then it is okay. System: VS 2010, Promotion v. 1.47.0
Question: Am I doing something wrong or is there a problem with the library / compiler? Can someone recommend a more stable implementation of unchanging strings for C ++?
test assigns its reference data to members Originally introduced as temporary contexts created from "code" L "" . Ohus When you try to use any of them in the copy constructor of wcstring on that line of crabbs, temporals are not present yet, so your reference Nothing reflects. I think that should be used more often than should the value boost :: const_string is what it does for it.
Comments
Post a Comment