473,473 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Compilation errors in templated code

template<template<typename T> class StoragePolicy>
class construction_info {
// Empty by default, specialize for other types.
};

template<template<typename> class StoragePolicy,
typename ConversionPolicy = DefaultConversions>
class Settings
{
public:

// Construct from construction_info.
Settings(const construction_info<StoragePolicy> &info)
: policy_(info)
{
policy_.Read();
}

private:

// A copy of a constructed data policy.
StoragePolicy<ConversionPolicy> policy_;
};

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template<typename ConversionPolicy>
class Xml
{
public:

// Typedef for quicker typing.
typedef construction_info<Xml> ctor_info; // ERROR!?

// Construct from ctor_info (definition after the class).
Xml(const ctor_info &info)
: c_info_(info) { }

void Read() {
std::cout << "XMLREAD" << std::endl;
}

private:
ctor_info c_info_; // Construction info
};

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template<>
class construction_info<Xml>
{
public:
construction_info(const std::string &filepath)
: filepath_(filepath) {}

std::string filepath_;
};

typedef construction_info<Xml> make_xml;

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Settings<Xml> xml( make_xml("D:\\file.xml") );

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// DJGPP compiles everything, but msvc.net2k3
// issues this:
//
// d:\code\tests\sett\xml.hpp(19): error C3200:
// 'Xml<ConversionPolicy>' : invalid template argument
// for template parameter 'StoragePolicy', expected a class template
//
// d:\code\tests\sett\xml.hpp(19): error C3200:
// 'Xml<ConversionPolicy>' : invalid template argument
// for template parameter 'StoragePolicy', expected a class template
// with
// [
// ConversionPolicy=DefaultConversions
// ]
//

Any suggestions?
Jul 22 '05 #1
7 2515
Saulius wrote:
template<template<typename T> class StoragePolicy>
What's that supposed to mean?
class construction_info {
// Empty by default, specialize for other types.
};
....
Any suggestions?


ITYM:

template< typename StoragePolicy >
class construction_info {
// Empty by default, specialize for other types.
};

Jul 22 '05 #2
Jeff Schwab wrote:
Saulius wrote:
template<template<typename T> class StoragePolicy>

What's that supposed to mean?
class construction_info {
// Empty by default, specialize for other types.
};

...
Any suggestions?

ITYM:

template< typename StoragePolicy >
class construction_info {
// Empty by default, specialize for other types.
};


Augh! Ignore that, please. :(

Your code compiles just fine with GCC 3.3.

Jul 22 '05 #3
Saulius wrote in news:a3**************************@posting.google.c om:
template<typename ConversionPolicy>
class Xml
{
public:

// Typedef for quicker typing.
typedef construction_info<Xml> ctor_info; // ERROR!?
typedef construction_info< ::Xml > ctor_info;

Within the declaration of this class template Xml is the type
Xml< ConversionPolicy > *not* the template, the explicit
namespace qualification fixes that.


// Construct from ctor_info (definition after the class).


Note that the space in "< ::Xml" is important, without it you
get a di/trigraph and therfore some wierd compilation error.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #4
Rob Williscroft <rt*@freenet.REMOVE.co.uk> wrote in message news:<Xn********************************@195.129.1 10.131>...
Saulius wrote in news:a3**************************@posting.google.c om:
template<typename ConversionPolicy>
class Xml
{
public:

// Typedef for quicker typing.
typedef construction_info<Xml> ctor_info; // ERROR!?


typedef construction_info< ::Xml > ctor_info;

Within the declaration of this class template Xml is the type
Xml< ConversionPolicy > *not* the template, the explicit
namespace qualification fixes that.


// Construct from ctor_info (definition after the class).


Note that the space in "< ::Xml" is important, without it you
get a di/trigraph and therfore some wierd compilation error.

Rob.


Now it won`t let me specialize construction_info for Xml:

d:\code\tests\sett\xml.hpp(44): error C2908: explicit specialization;
'settings::construction_info<StoragePolicy>' has already been
instantiated
with
[
StoragePolicy=settings::Xml
]
d:\code\tests\sett\xml.hpp(50): error C2766: explicit specialization;
'settings::construction_info<settings::Xml>' has already been defined

(settings is the namespace in witch everything`s written)
Jul 22 '05 #5
Saulius wrote in news:a3**************************@posting.google.c om:
Now it won`t let me specialize construction_info for Xml:

d:\code\tests\sett\xml.hpp(44): error C2908: explicit specialization;
'settings::construction_info<StoragePolicy>' has already been
instantiated
with
[
StoragePolicy=settings::Xml
]
d:\code\tests\sett\xml.hpp(50): error C2766: explicit specialization;
'settings::construction_info<settings::Xml>' has already been defined

(settings is the namespace in witch everything`s written)


Ok I actually spotted this the first time, but there were
other errors (DefaultConversions, std::cout, std::endl),
that I assumed, wrongly, had something to do with it.

CBuilder preview (an EDG front end) gives the error a bit
more legably than VC7.1 : explicit specialization of class
.... must precede its first use.

I had to put:

#include <iostream>
#include <ostream>
#include <string>

class DefaultConversions {};

/* from original code ...
*/
template<template<typename T> class StoragePolicy>
class construction_info {
// Empty by default, specialize for other types.
};

/* forward declare the Xml template
*/
template <typename ConversionPolicy> class Xml;

/* Moved forward ...
*/
template<>
class construction_info< Xml >
{
public:
construction_info(const std::string &filepath)
: filepath_(filepath) {}

std::string filepath_;
};

As the begining of your posted code to fix this, remove the
specialization from the end ofcourse :).
Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #6

"Saulius" <sa****@balticum-tv.lt> wrote in message
news:a3**************************@posting.google.c om...
template<template<typename T> class StoragePolicy>
class construction_info {
// Empty by default, specialize for other types.
};

template<template<typename> class StoragePolicy,
typename ConversionPolicy = DefaultConversions>
class Settings
{
public:

// Construct from construction_info.
Settings(const construction_info<StoragePolicy> &info)
: policy_(info)
{
policy_.Read();
}

private:

// A copy of a constructed data policy.
StoragePolicy<ConversionPolicy> policy_;
};

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template<typename ConversionPolicy>
class Xml
{
public:

// Typedef for quicker typing.
typedef construction_info<Xml> ctor_info; // ERROR!?


Note you are defining a templated class so the template parameters are
deduced when you instantiate the class.
simply remove the template parameters i.e:
typedef construction_info ctor_info;

This should compile fine then if you include the <string> header for
std::string.

HTH.
Jul 22 '05 #7

"Jumbo @uko2.co.uk>" <pcr1000011<nospam> wrote in message
news:10***************@news.minx.net.uk...

"Saulius" <sa****@balticum-tv.lt> wrote in message
news:a3**************************@posting.google.c om...
template<template<typename T> class StoragePolicy>
class construction_info {
// Empty by default, specialize for other types.
};

template<template<typename> class StoragePolicy,
typename ConversionPolicy = DefaultConversions>
class Settings
{
public:

// Construct from construction_info.
Settings(const construction_info<StoragePolicy> &info)
: policy_(info)
{
policy_.Read();
}

private:

// A copy of a constructed data policy.
StoragePolicy<ConversionPolicy> policy_;
};

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template<typename ConversionPolicy>
class Xml
{
public:

// Typedef for quicker typing.
typedef construction_info<Xml> ctor_info; // ERROR!?
Note you are

oops typedeffing I mean
a templated class so the template parameters are deduced when you instantiate the class.
simply remove the template parameters i.e:
typedef construction_info ctor_info;

This should compile fine then if you include the <string> header for
std::string.

HTH.

How did this end up here? :-s


Jul 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dennis Francis B. Tutanes | last post by:
$B$*@$OC$K$J$C$F$*$j$^$9!#(B $B%D%?%M%9(B@TSTI$B$G$9!#(B SEND-PR: -*- send-pr -*- SEND-PR: Lines starting with `SEND-PR' will be removed automatically, as SEND-PR: will all comments (text...
0
by: Jason Jefferies | last post by:
I'm currently converting a number of applications written using the MFC in vc++ version 6 into a workable .NET solution. Just trying to build the apps in version 7 without worrying about...
2
by: Steve | last post by:
Hi I'm receiving the following error whenever a new build is placed onto our production server: Timed out waiting for a program to execute. The command being executed was...
4
by: wxforecaster | last post by:
As alluded to in my post yesterday, I'm trying to compile a common C utility in Windows. It's only reference is to zlib.h, which needs zconf.h and in turn libz.a On Unix I've compiled this with...
0
by: Larry Lard | last post by:
Recently we've been on a code quality drive and have eliminated all compilation warnings from our code. To preserve this state, we've turned 'Treat warnings as errors' to 'All' in all our projects...
0
by: clintonb | last post by:
I converted a Web Site project to a Web Application project using the instructions found on this page: http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx One thing I did differently...
6
by: mathieu | last post by:
Hi there, I am currently struggling with a compiler error on a templated code. The error is complete non-sense. I think the issue here is that I am including files in a loop. To handle templates...
5
by: Sujal | last post by:
In below program, I'm getting below compilation errors error C2621: member '_tag_nodes_::node_' of union '_tag_nodes_' has copy constructor error C2621: member '_tag_nodes_::linkednode_' of...
0
by: Mickey | last post by:
I am a classic asp and php developer so this compilation stuff is new to me. What would cause pages to "spontaneously" develop compilation errors. They are fine one minute and then poof, an error...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.