Questions tagged [lexical-cast]

69 questions
0
votes
2 answers

Extended boost::lexical_cast for other class datatypes

Is it possible to extend boost::lexical_cast to handle other datatypes, without actually modifying those classes? In my case, I want to extend it to handle things like cv::Point and cv::Point3, taking a string-separated list of coordinates and…
Yeraze
  • 3,269
  • 4
  • 28
  • 42
0
votes
1 answer

bad_lexical_cast exception on overloaded operator ">>"

I've overloaded operator ">>" for an Enum: #include #include using namespace std; enum MyEnum { ONE = 0, TWO, TREE, MAX }; const char* MyEnumString[MAX] = { "ONE" …
Sanich
  • 1,739
  • 6
  • 25
  • 43
0
votes
0 answers

C++ check if string is numeric

I need to check if an std::string is a number. By number I mean either a whole number or a number with a decimal point (base 10). I'm fine with the limits that long long provides so anything outside that I don't care about. I don't have boost, but…
LeviX
  • 3,096
  • 3
  • 28
  • 41
0
votes
1 answer

Parse and cast csv based on map type c++

Does anyone know of any libraries or examples which will read/write a csv and depending on map (potentially nested) passed to infer the type and populate the map. This will probably involve some recursive templated code. ie map
Bloogle
  • 3
  • 1
0
votes
1 answer

Using boost::lexical_cast(string)

I am a beginner and need an explanation as to why this doesn't work: string myArray[620223]; //myArray is then populated with a while loop using ifstream and getline string myString = myArray[9]; double myValue; try { myValue =…
0
votes
1 answer

boost::lexical_cast with positive sign

How can I make boost::lexical_cast include a positive sign when converting to std::string? I intend to do the same as: snprintf( someArray, someSize, "My string which needs sign %+d", someDigit );. Here, someDigit would be put in the string as…
Raf Berkvens
  • 167
  • 1
  • 8
0
votes
1 answer

boost::lexical_cast without runtime libraries

I'm in a situation where I would like to use boost::lexical_cast, but cannot make use of C/C++ runtime libraries, and thus cannot use lexical_cast. I don't know Boost extremely well, but I have seen the use of blocks such as: #ifdef…
Austin
  • 140
  • 1
  • 10
-1
votes
1 answer

C++ header file to be included for lexical cast

My compiler(GCC for C++) throws error when I include the #include header file for converting integer type to string type for some program. Can anyone help me with this? This is for a small code in C++, I've tried it for the first…
Stan_Dodo
  • 1
  • 3
-5
votes
2 answers

Strange Boost::Lexical_cast conversion

To make it short, here is the code : std::string m_specs = "f500000"; float m_sten = 21.0; std::cout << m_specs << std::endl; m_specs = "f" + boost::lexical_cast(m_sten); std::cout << m_specs << std::endl; The first output will be :…
Marion
  • 13
  • 1
  • 5
1 2 3 4
5