473,396 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

funny template variable declaration

in boost spirit examples some code example is given:

rule<r = *anychar_p;
parse("hello world", r);

what does the empty template bracket mean?

Dec 8 '06 #1
4 1935

Peter wrote:
in boost spirit examples some code example is given:

rule<r = *anychar_p;
parse("hello world", r);

what does the empty template bracket mean?
It means that its a template and that its using a default template
variable.
silly example:

#include <iostream>
#include <ostream>

template< typename T = int >
struct Test
{
T t;
Test() : t() { }
const T& get() const { return t; }
};

int main()
{
Test< test;
std::cout << test.get() << std::endl;
}

If you remove the empty < you'll get the something like the following
error:
"missing template arguements"

Dec 8 '06 #2
Peter wrote:
in boost spirit examples some code example is given:

rule<r = *anychar_p;
parse("hello world", r);

what does the empty template bracket mean?
Use the deafualts.

i.e.

template <typename T = intclass X;

X<> * y;

Dec 8 '06 #3

Peter wrote:
in boost spirit examples some code example is given:

rule<r = *anychar_p;
parse("hello world", r);

what does the empty template bracket mean?
rule is a template that can take 3 parameters but provides defaults for
all 3. The above use uses the defaults for every parameter.

Dec 8 '06 #4

Peter wrote:
in boost spirit examples some code example is given:

rule<r = *anychar_p;
parse("hello world", r);

what does the empty template bracket mean?
rule is a template that can take 3 parameters but provides defaults for
all 3. The above use uses the defaults for every parameter.

Dec 9 '06 #5

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

Similar topics

11
by: Johan | last post by:
Hi Can somebody explain to me why I get this warning message and how I can solve this warning message. Thanks a lot Johan In member function `void
6
by: paul | last post by:
When I compile class B shown below, in VC Express 2005, I get error C2061: syntax error : identifier '{ctor}. Would appreciate any info on how to avoid the error. ref class X{ X(); ~X(); }; ...
2
by: pagekb | last post by:
Hello, I'm having some difficulty compiling template classes as containers for other template objects. Specifically, I have a hierarchy of template classes that contain each other. Template...
2
by: Alan | last post by:
Does a template class declaration, like template <class T> have to come immediately prior to the declaration of the function, e.g., T do_something (T something) { . . . } that uses it?
9
by: rtalbot | last post by:
I've got a container that looks like this: template <class T> class Foo { public: Foo() : _data(), _status(1) { } Foo(T) : _data(T), _status(0) { } ~Foo() { }
5
by: Gernot Frisch | last post by:
// - in my xy.cpp file -- template <const int Ttex, const int Tcol, const int Tlight, int TzBuffer> struct MyFragmentShader { static const int varying_count = Ttex*2 + Tcol*3 + Tlight; }; ...
0
by: James Kanze | last post by:
On May 16, 9:34 am, Paavo Helde <nob...@ebi.eewrote:
2
by: Hel | last post by:
Hi, I'm sure you are familiar with this problem: A.h: template <unsigned Nstruct A { static const unsigned a; };
4
by: Ed | last post by:
Hi, guys, In C language manner, we need to put a "struct" token before one struct variable declaration like following. <code> struct Apple { float Price; };
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.