Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6725589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:49:33+00:00 2026-05-26T09:49:33+00:00

I’m having issues with boost::lexical_cast. I am trying to use it on a class

  • 0

I’m having issues with boost::lexical_cast. I am trying to use it on a class from the GLM (OpenGL Mathematics) library.

To allow for lexical casting, I have implemented operator<< functions for the class in question:

template <class T>
std::ostream& operator<<(std::ostream& out, const glm::detail::tvec2<T>& vec)
{
  out << vec.x << " " << vec.y;
  return out;
}

template <class T>
std::istream& operator>>(std::istream& in, glm::detail::tvec2<T>& vec)
{
  in >> vec.x;
  in >> vec.y;
  return in;
}

I tested the operators like so:

std::cout <<  glm::ivec2(1, 1) << glm::vec2(1.0f, 1.0f);

and:

std::stringstream ss("640 480");
glm::ivec2 pt;
ss >> pt;
std::cout << pt << std::endl;

This works just fine, however if I try this:

glm::ivec2 pt = boost::lexical_cast<glm::ivec2>("1 1");

I get the following error:

/usr/include/boost/lexical_cast.hpp: In member function ‘bool boost::detail::lexical_stream_limited_src<CharT, Base, Traits>::operator>>(InputStreamable&) [with InputStreamable = glm::detail::tvec2<int>, CharT = char, Base = std::basic_streambuf<char>, Traits = std::char_traits<char>]’:
/usr/include/boost/lexical_cast.hpp:1151:13:   instantiated from ‘Target boost::detail::lexical_cast(typename boost::call_traits<B>::param_type, CharT*, std::size_t) [with Target = glm::detail::tvec2<int>, Source = const char*, bool Unlimited = false, CharT = char, typename boost::call_traits<B>::param_type = const char* const, std::size_t = long unsigned int]’
/usr/include/boost/lexical_cast.hpp:1174:77:   instantiated from ‘Target boost::lexical_cast(const Source&) [with Target = glm::detail::tvec2<int>, Source = char [8]]’
test2.cpp:41:59:   instantiated from here
/usr/include/boost/lexical_cast.hpp:785:29: error: cannot bind ‘std::basic_istream<char>’ lvalue to ‘std::basic_istream<char>&&’
/usr/include/c++/4.6/istream:852:5: error:   initializing argument 1 of ‘std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&) [with _CharT = char, _Traits = std::char_traits<char>, _Tp = glm::detail::tvec2<int>]’

EDIT: It seems the error only occurs if headers for Boost.PropertyTree are included.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:49:34+00:00Added an answer on May 26, 2026 at 9:49 am

    The answer was found by another, so I’ll leave it here.

    He mentioned something about argument dependent lookup, and suggested that the stream operators be placed in the glm::detail namepace like so:

    namespace glm {
    namespace detail {
    
    template <class T>
    std::ostream& operator<<(std::ostream& out, const glm::detail::tvec2<T>& vec)
    {
        out << vec.x << " " << vec.y;
        return out;
    }
    
    template <class T>
    std::istream& operator>>(std::istream& in, glm::detail::tvec2<T>& vec)
    {
        in >> vec.x;
        if (in.good() && in.ignore(256, ' ').good())
            in >> vec.y;
        return in;
    }
    
    }} // glm::detail
    

    After that, everything works fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.