Reply to comment

bad example

Well, the Boost preprocessor metaprogramming library is definitely very useful, but I think your example is imho a bit unfortunately chosen and boost isn't the right thing for this. You'll get bloated code and you have a upper limit of arguments. And it's hard to read. ;)
Why not use the following for this task?

class toStrings
{
	list<string> l;
public:
	template <typename Typ>
	toStrings operator+(Typ obj)
	{
		l.push_back(lexical_cast<string>(obj));
		return *this;
	}
 
	list<string> get(){return l;}
};

usage:
list<string> foo = (toStrings()+"hello"+"world"+42+'h'+123.45f).get();

greetings, iliis

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • Lines and paragraphs break automatically.
  • You may post PHP code. You should include <?php ?> tags.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Images can be added to this post.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.