template instantiation
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: template instantiation

Threaded View

  1. #1
    Join Date
    Sep 2010

    namespace problems

    Hi, The simplified code compiles correctly under GCC but not MSVC. why ? If I put Option struct in its own named namespace or remove the namespace Util, it compiles correclty. How can I make it work for both compilers ?
    #include <vector>
    #include <iostream>
    /*default vector IO*/
    template <class T>
    std::ostream& operator << (std::ostream& os, const std::vector<T>& p) {
    	return os;
    template <class T>
    std::istream& operator >> (std::istream& is, std::vector<T>& p) {
    	return is;
    /*Utililty functions*/
    namespace Util {
    	struct Option {
    		friend std::istream& operator >> (std::istream& is, Option& p) {
    			return is;
    		friend std::ostream& operator << (std::ostream& os, const Option& p) {
    			return os;
    	struct Parameters{
    		std::vector<int>* test;
    		bool read(std::string str,std::istream& is) {
    			is >> *test;
    			return false;
    void main() {
    	Util::Parameters params_vec_int;
    Last edited by dshawul; January 26th, 2013 at 11:18 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)