Boost logo

Boost Users :

Subject: Re: [Boost-users] How to convert std::string into basic_string
From: manish4gupta (manish_at_[hidden])
Date: 2009-09-16 20:58:53


This is ok but i have to convert string into boost string. if i use the
method as suggested.

string s = "hello";
std::basic_string<wchar_t> ts(s.begin(), s.end());
char_string y = ts;

I am getting the following error.

run.cpp: In function ‘int main()’:
run.cpp:63: error: conversion from ‘std::basic_string<wchar_t,
std::char_traits<wchar_t>, std::allocator<wchar_t> >’ to non-scalar type
‘boost::interprocess_container::basic_string<char, std::char_traits<char>,
boost::interprocess:allocator<char,
boost::interprocess::segment_manager<char,
:boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family,
boost::interprocess::offset_ptr<void>, 0u>, boost::interprocess::iset_index>
> >’ requested

> I am new to boost-interprocess. I don't know much about this. Any example
> converting the std:: string/c-string into boost basic_string will help me.
> I
> will be really thankful to you.

basic_string is not boost, it's plain STL.

from <string>:

typedef basic_string<char> string;

To assign two different basic_strings:

        std::string s = "foobar";
        std::basic_string<wchar_t> ws(s.begin(), s.end());

Chris

-- 
echo mailto: NOSPAM !#$.'<*>'|sed 's. ..'|tr "<*> !#:2" org_at_fr33z3
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- 
View this message in context: http://www.nabble.com/How-to-convert-std%3A%3Astring-into-basic_string-tp25446943p25483524.html
Sent from the Boost - Users mailing list archive at Nabble.com.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net