is this legal c++0x?

If subscript operator is legal as non-member function in c++0x, could
we write?



template <typename...Types, int N>
auto operator[](tuple<Types...> && tup, int n = N) -> constexpr
decltype(get<N>(tup))
{
	return get<N>(tup);
}


is this legal c++0x? Because if it is. We could write.

tuple<int, float, string> mytuple;

mytuple[2] = 12;

and expressions in array-like notation.

-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
german
5/9/2009 11:04:01 AM
comp.lang.c++.moderated 10707 articles. 11 followers. allnor (8507) is leader. Post Follow

1 Replies
230 Views

Similar Articles

[PageSpeed] 44
german diago wrote:
> If subscript operator is legal as non-member function in c++0x, could
> we write?
> 
> 
> 
> template <typename...Types, int N>
> auto operator[](tuple<Types...> && tup, int n = N) -> constexpr
> decltype(get<N>(tup))
> {
> 	return get<N>(tup);
> }
> 
> 
> is this legal c++0x? Because if it is. We could write.
> 
> tuple<int, float, string> mytuple;
> 
> mytuple[2] = 12;

Sorry, but N cannot be deduced in this way.

Furthermore, we would get functions with weird signatures,
since default values are not part of it.

-- 
Dragan

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Dragan
5/15/2009 5:43:39 AM
Reply:
Similar Artilces:

I did not know that was legal
I have using Intellij. One thing it often does in make suggestions on how to improve your code. One it made, I thought was illegal till I tried it out. If you have code like this: case 1: int x = expression; break; case 2: x = expression; break; that is LEGAL even though program flow does not flow through the definition. You DON'T have to promote x out of the switch. You can think of it that it works AS IF you always fell through each case. The key to this mystery is understanding that local variables are not actually allocated where you define them. They all get alloc...

K&R C style
I like to use a good C style when I write C code.Now I am using K&R C style but only a little.Because I don't completely know K&R C style.So where can I find the whole description in K&R C style? -- comp.lang.c.moderated - moderation address: clcm@plethora.net In <clcm-20040929-0026@plethora.net> "Bruce Sam" <persevreman@yahoo.com.cn> writes: >I like to use a good C style when I write C code.Now I am using K&R >C style but only a little.Because I don't completely know K&R C >style.So where can I find the whole description i...

[C#] Question: Change button text during runtime?
Hi all experts out there! Here is a quick question. I want to change one of my buttons text label during runtime how do I do that in best possible way in C# ? I want to do something like this "Start game" -> "Stop game" Thanks in advance Slusken http://www.userhealth.tk "slusken" <userhealth@email.com> wrote in message news:sfRHe.143160$dP1.497163@newsc.telia.net... > Hi all experts out there! > Here is a quick question. I want to change one of my buttons text label > during runtime how do I do that in best possible way in C#...

US-TX-San Antonio: Programmer: C++, Perl, XML, Linx, RDMS, C-P. (45311657650)
US-TX-San Antonio: Programmer: C++, Perl, XML, Linx, RDMS, C-P. (45311657650) ============================================================================= Position: Programmer Reference: PMG00004 Location: San Antonio TX Duration: contract-perm Skills: C++ Perl XML RDMS QT Unix/Linux Scope: Responsibilities Include � Designing, modifying, developing, writing and implementing software applications � Supporting and installing so...

C++ API: Convert double matrix to string for console output
hello CSSM I have a problem converting the double matrix returned as a mwArray to a string for output in a C++ application calling a matlab generated C++ shared library: in short does the .ToString method of mwArray class work? ....but please read on MATLAB Version 7.0.1.24496 (R14) Service Pack 1 MATLAB Compiler Version 4.1 (R14SP1) using MSVC7.01 vs2003 Pro code snippet based on the matrixdriver.cpp example double data[] = {1,2,3,4,5,6,7,8,9}; mwArray in1(3, 3, mxDOUBLE_CLASS, mxREAL); mwArray in2(3, 3, mxDOUBLE_CLASS, mxREAL); in1.SetData(data, 9); ...

Building C extensions
Well I'm just courious: if I want to buid a C extension, I shoul use the same compiler that has been used to build python (right?). Since python has been built using Visual C, how can I build an extension if I don't have Visual Studio? PAolo Paolo Pantaleo wrote: > Well I'm just courious: if I want to buid a C extension, I shoul use > the same compiler that has been used to build python (right?). Since > python has been built using Visual C, how can I build an extension if > I don't have Visual Studio? > > PAolo Use mingw32. It should work fine for most ex...

Programming serial interface with C?
hello, do you know a good tutorial etc about programming serial interfaces in c and under linux? i only know the Serial programming HOWTO, but i want to try another one. or do you have a program that reads the serial ports? thanks in advance magelord@t-online.de (Math55) wrote: >hello, do you know a good tutorial etc about programming serial >interfaces in c and under linux? i only know the Serial programming >HOWTO, but i want to try another one. or do you have a program that >reads the serial ports? > >thanks in advance The Linux Serial-Programming-HOWTO ...

Transparent packed C arrays
I was under impression that there was a Perl module which allowed "transparent" (via overloading) access to vectors represented as C arrays, e.g., to $array = pack('L*',@vec); so that r/w access, arithmetic operations etc. work without explicit unpack()ing. However, I could not find it quickly via CPAN search. Any hints? Thanks, Ilya "Ilya Zakharevich" > wrote ... >I was under impression that there was a Perl module which allowed > "transparent" (via overloading) access to vectors represented as C > arrays, e.g., to > > $array =...

US-TX-Austin: Sr Host SW Apps Eng., 5+yrs exp C, C#, C++, Architect/Write code; (45340457631)
US-TX-Austin: Sr Host SW Apps Eng., 5+yrs exp C, C#, C++, Architect/Write code; (45340457631) ============================================================================================= Position: Sr Host SW Apps Eng. Reference: SMC01958 Location: Austin TX Duration: Perm Skills: Masters/Bachelor of Science Degree in Electrical Engineering or Computer Science 5+yrs exp with C, C#, and/or C++. Exp architecting and writing code for several features within a system along with the development and test of lo...

Re: SAS run via a web browser
Vincent, Interesting concept and, if SI were to go along with it, the pricing model could end up being even more complex based upon the offerings. My first thought was, wow, what a great concept for offering Enterprise Miner. However, upon more thought, I realized that doing any analyses that way would risk others seeing either the data, the results, or both. Privacy and the security of proprietary information would have to be assured for the concept to work in the business community. Art --------- On Fri, 25 Dec 2009 22:19:15 -0500, Vincent Granville <vincentg@DATASHAPI...

ATTENTION:
NONE I am a highly qualified consultant looking for a contract mission or a turn-key project in the following domains: - Software development using C/C++/C#, Java, and Perl - UML-OO Anlysis and Design - RDBMS/SQL Modelling and Implementation (Oracle, DB2, Informix, Sybase, InterBase) - Unix/Linux based system architecture and cross-platform development - Unix to/from Windows XP/NT system ports. - IT Audits. With kind regards. ...

More about C and C++
Hello, I have wrote: >I will resume it like this: >On the criterias of "complexity" and "difficulty", the C and C++ >programming languages are more complex and difficult than Object >Pascal for example, so since they are more complex and difficult they >are likely to create something like a darwinian filter who don't let >the weaker humans among us humans to cross or to climb the social >ladder, this is why i think that C and C++ do participate to social >darwinism, this is why i say that C and C++ are bad. Josep...

Is this legal?
Earlier, I blamed Python for being unable to parse this, but just to be sure, is this legal HTML (at least the part with " // </ht ml> " ? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><title>Choke on this</title> <script language="JavaScript"> <!-- // </ht ml> - this is a comment in JavaScript --> </script> </head> <body> Hey there </body> </html> G. wrote: > Earlier, I blamed Python for being unable to parse this, but just to be > ...

Network share Windows creation C or C++
Hiya, Im thinking about making a program at the moment which is quite large, I have no problem with any of the sub systems really except one, I would like to be able to make a folder to my network places, this folder could already be on the computer in the network and I simple want to change the attributes to enable is to be viewed on the network, Does anyone have any ideas of the mechanism of how making a folder networked is done in windows? Is it done in the registry?? Im planning on doing this in C, C++ or VB. I respect the fact that the latter to my be more useful for windows based app...

GUI/MFC/C++ developer position in London, UK
The company, Biotronics3D, based in East London,UK is a new and dynamic venture dealing in advanced technologies. We market novel and innovative solutions to the medical international market. It is created by a group of scientists and businessmen, with ample experience in this market sector. The patented technology allows doctors to improve their diagnostic efficiency and accuracy via a set of software and hardware tools. We have many strategic partnerships with Universities and Hospitals. Our current strategy is to expand our research and development activities by fusing technologies ...

getting os/2 version in c
Does anybody know how to simply get the version and release in C from os/2 or eCs. I'm using Visual Age C 3.0. Using DosQuerySysInfo always gives the same info on Warp 4 and eCs although eCs is 4.5. I found uname but this is unavilable in Visual Age C. Keith On Thu, 9 Jun 2005 07:47:17 UTC, "Keith" <ktmos2@softhome.net> wrote: > Does anybody know how to simply get the version and release in C from os/2 > or eCs. > I'm using Visual Age C 3.0. > Using DosQuerySysInfo always gives the same info on Warp 4 and eCs although > eCs is 4.5...

C/C++ Matlab library?
Hi, I just came to realize that Matlab is extremely slow for my data visualization code. But at the same time, I like the functionality that Matlab provides. I looked around and Mathworks has a c/c== Matlab graphics library package. Unofrtunately, it cannot be purchased for the student version of Matlab. Are there any other packages out there that I could use with my student version of Matlab? Thanks. ...

Sr Software Engineer needed-C,C++, DEBUG, LINUX, NETWORKS, WINDOWS OS,MFC, C#, .NET, XML,Cold Fusion/SQL
Dear All I will appreciate if you mail your updated resume asap along with your salary expectation on w2 basis Assignment Information Project Location: WA Project Name: EST - Evaluation Engineering Desired Start Date: 06/21/2004 Length of Engagement: 6 mo Shift: 01 Primary Skill: C++ Other Skills: C, DEBUG, LINUX, NETWORKS, WINDOWS OS Roles & Responsibilities Update 6/15; the client added the following skills to the Necessary MUST HAVES: 1. MFC, C#, .NET, XML, MFC 2. no change 3. no change ...

Pointer to &array[-1]
I've run into some code that uses this idiom for looping through an array some_type *ptr = &some_type_array[0] - 1; while (*(++ptr) != some_val) ... What I'm wondering is whether forming the pointer (&some_type_array[0] - 1) is legal. I realize that this array is never used to access memory. BTW, in the subject line I used a -1 index for brevity. I'm assuming both forms are either legal or illegal, and it is not the case that one is legal and the other is not. -- comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must have an approp...

C linkage problem with ACE on windows
Compiling a program using ACE + MSVC++8, got lots of errors and some are listed as below: Error 2 error C2894: templates cannot be declared to have 'C' linkage c:\program files\microsoft visual studio 8\vc\include\iosfwd 39 Error 39 error C2733: second C linkage of overloaded function 'ACE_OS::atoi' not allowed c:\tmp\ace+tao+ciao\ace_wrappers\ace\os_ns_stdlib.h 79 Error 41 error C2733: second C linkage of overloaded function 'ACE_OS::getenv' not allowed c:\tmp\ace+tao+ciao\ace_wrappers\ace\os_ns_stdlib.h 116 ... ... When i changed #include <string>...

US-TX-Fort Worth: Java, C/C++, SABRE , NT/XP platform (45355032400)
US-TX-Fort Worth: Java, C/C++, SABRE , NT/XP platform (45355032400) =================================================================== Position: JAVA Developer Reference: MLS00014 Location: Fort Worth TX Duration: 4mo + Skills: 5+ YEARS Knowledge of SABRE Reservation system and IBM Kiosk platform a plus. Java, C/C++, on a windows NT/XP platform Scope: Provide senior level support utilizing Java, C/C++ on a Windows NT/Windows XP platform. strong knowledge of processes and procedu...

In Dev-C++, how can I make a rounding to nearest integer?
Here are the funny results I got from Dev-C++, what I need is rounding to nearest integer. How can I do that in Dev-C++? a = -1 -1 -1 -1 1 1 2 2 2 1 b = round(a) -0.729627 -0.9540721 -0.2123411 -0.078923 0.321015 0.9876552 1.123422 1.632136 1.234538 0.765442 c = int(a) 0 0 0 0 0 0 1 1 1 0 My required data. c = -1 -1 0 0 0 1 1 2 1 1 Thank you. "Mr. Ken" <Mr. Ken@asdf> wrote in message news:44756dac$1@news.starhub.net.sg... > Here are the funny results I got from Dev-C++, what I need is rounding to > nearest integer. > How can I do that in Dev-...

US-TX-Round Rock: Netware OS Developer, C, C++, JAVA, XML, OOP, RAID; 9M (45320832403)
US-TX-Round Rock: Netware OS Developer, C, C++, JAVA, XML, OOP, RAID; 9M (45320832403) ====================================================================================== Position: Netware OS Developer Reference: SMC01664 Location: Round Rock TX Duration: 9M Skills: Development with Netware Operating System Language Skills: C , C++, JAVA , XML, Object Oriented Programming, databases Metrowerks C Compiler, Build process. Makefiles Install process on Netware, IPS scripts. Understand Raid...

US-TX-Austin: Business Support Spc., Master/Factory planning, MS Office; C-P (45316232410)
US-TX-Austin: Business Support Spc., Master/Factory planning, MS Office; C-P (45316232410) ========================================================================================== Position: Business Support Spc. Reference: SMC01635 Location: Austin TX Duration: C-P Skills: Bachelor Degree in Information Systems; Computer Science; Engineering; or related field. 5+ years direct IT/IS experience in business integration and system support. Strong understanding of master and factory planning in a ...

Windows Programming with C++
I picked up this book as an intro to win32 programming. I do like the book because the examples are small and easy to uderstand. I am running into the problem that after I type in the programs they don't work. I am using the bloodshed dev C++ compiler and I use the templates that came with the program to reduce errors. Has anyone used this book and run into the same problems as me. Is there an erreta for this book? "JoeC" <enki034@yahoo.com> wrote in message news:1114310463.199294.89780@o13g2000cwo.googlegroups.com... > I picked up this book as an intr...