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 1008109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:43:14+00:00 2026-05-16T08:43:14+00:00

This code compiles and works as expected (it throws at runtime, but never mind):

  • 0

This code compiles and works as expected (it throws at runtime, but never mind):

#include <iostream>
#include <boost/property_tree/ptree.hpp>

void foo(boost::property_tree::ptree &pt) 
{
    std::cout << pt.get<std::string>("path"); // <---
}

int main()
{
    boost::property_tree::ptree pt;
    foo(pt);
    return 0;
}

But as soon as I add templates and change the foo prototype into

template<class ptree>
void foo(ptree &pt)

I get an error in GCC:

test_ptree.cpp: In function ‘void foo(ptree&)’:
test_ptree.cpp:7: error: expected primary-expression before ‘>’ token

but no errors with MSVC++! The error is in the marked line <---. And again, if I change the problem line into

--- std::cout << pt.get<std::string>("path"); // <---
+++ std::cout << pt.get("path", "default value");

the error disappears (the problem is in explicit <std::string>).

Boost.PropertyTree requires Boost >= 1.41. Please help me to understand and fix this error.


See Templates: template function not playing well with class’s template member function — a similar popular question containing other good answers and explanations.

  • 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-16T08:43:15+00:00Added an answer on May 16, 2026 at 8:43 am

    You need to do:

    std::cout << pt.template get<std::string>("path");
    

    Use template in the same situation as typename, except for template members instead of types.

    (That is, since pt::get is a template member dependent on a template parameter, you need to tell the compiler it’s a template.)

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

Sidebar

Ask A Question

Stats

  • Questions 535k
  • Answers 535k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are lots of reasons to build a new 3D… May 17, 2026 at 1:11 am
  • Editorial Team
    Editorial Team added an answer Even though you've described this as a 1-many relationship, I'd… May 17, 2026 at 1:11 am
  • Editorial Team
    Editorial Team added an answer Then your best bet is to put your feed in… May 17, 2026 at 1:11 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Running the following C# code through NUnit yields Test.ControllerTest.TestSanity: Expected: `<System.DivideByZeroException>` But was: null
Example code: #include <cstdlib> #include <iostream> using namespace std; class A { public: A(int
Say I have this code - public interface ParentInterface1 { public List<? extends ChildInterface1>
I wonder is anyone can look at this code and tell me why calling
Consider the following code (it's a little long, but hopefully you can follow): class
Stupid nHibernate noob question, but I can't find the answer anywhere ... I have
I truly love NUnit's new(er) ability to test for expected exception testing, ie: var
So, I have a code, that compiled on MSVC 9 and some previous (dunno
I'm having a go at making a Silverlight2 UserControl to emulate the basic functionality
I'm using DataContract/DataMembers to serialise my class to JSON for a webservice, and it

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.