Thursday, July 28, 2016

Digest for comp.lang.c++@googlegroups.com - 25 updates in 9 topics

Daniel <danielaparker@gmail.com>: Jul 28 02:31PM -0700

I want to have a class template that has a specialization for bool, and also for std::vector<bool>::const_reference if that type differs from bool.
 
I came up with this:
 
template<class T, class Enable = void>
class A
{
public:
A()
{
std::cout << "default" << std::endl;
}
};
 
 
template <class T>
class A<T,typename std::enable_if<std::is_same<T,bool>::value>::type>
{
public:
A()
{
std::cout << "bool" << std::endl;
}
 
};
 
template<class T>
class A<T,typename std::enable_if<std::is_same<T,
std::conditional<!std::is_same<bool,std::vector<bool>::const_reference>::value,
std::vector<bool>::const_reference,
void>::type>::value>::type>
{
public:
A()
{
std::cout << "std::vector<bool>::const_reference" << std::endl;
}
};
 
// With VS, the types are the same
A<std::vector<bool>::const_reference> a1; // With VS, prints bool
A<bool> a2; // With VS, prints bool
 
Is there a simpler way?
 
Thanks,
Daniel
"Öö Tiib" <ootiib@hot.ee>: Jul 28 04:00PM -0700

On Friday, 29 July 2016 00:31:27 UTC+3, Daniel wrote:
> I want to have a class template that has a specialization for bool, and
> also for std::vector<bool>::const_reference if that type differs from bool.
 
That is odd ... AFAIK it is *required* to be bool.
 
 
> I came up with this:
 
...
 
 
> Is there a simpler way?
 
Wasn't it simple enough?
May be if you write that, then it is simpler to follow logically:
 
template<class T>
class A< T, typename std::enable_if<
std::is_same< std::vector<bool>::const_reference, T>::value
&& !std::is_same<bool, T>::value >::type >
Lynn McGuire <lmc@winsim.com>: Jul 27 04:50PM -0500

"The 2016 Top Programming Languages"
http://spectrum.ieee.org/computing/software/the-2016-top-programming-languages
 
"C is No. 1, but big data is still the big winner"
 
Where is Fortran ?
 
Lynn
Ian Harvey <ian_harvey@bigpond.com>: Jul 28 01:07PM +1000

On 2016-07-28 07:50, Lynn McGuire wrote:
 
> http://spectrum.ieee.org/computing/software/the-2016-top-programming-languages
 
> "C is No. 1, but big data is still the big winner"
 
> Where is Fortran ?
 
Is that a rhetorical question?
 
Number 28 otherwise, depending on your weighting.
Richard Heathfield <rjh@cpax.org.uk>: Jul 28 07:17AM +0100

On 27/07/16 22:50, Lynn McGuire wrote:
 
> http://spectrum.ieee.org/computing/software/the-2016-top-programming-languages
 
> "C is No. 1, but big data is still the big winner"
 
> Where is Fortran ?
 
Have you checked down the back of the settee?
 
--
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within
jacobnavia <jacob@jacob.remcomp.fr>: Jul 28 09:28PM +0200

Le 27/07/2016 à 23:50, Lynn McGuire a écrit :
 
> "C is No. 1, but big data is still the big winner"
 
> Where is Fortran ?
 
> Lynn
 
Interesting
 
Nobody commented on why C++ went from the third to the fourth place.
"Öö Tiib" <ootiib@hot.ee>: Jul 28 03:08PM -0700

On Thursday, 28 July 2016 22:29:02 UTC+3, jacobnavia wrote:
 
> > Lynn
 
> Interesting
 
> Nobody commented on why C++ went from the third to the fourth place.
 
What it is? How to comment it? What went from where to where?
There that statistics programming language "R" is at #5 and
wins C#, PHP and Javascript. Really? At place #11 there is "Andruino".
Isn't it hardware platform? :D It feels like some sort of bad joke.
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jul 28 07:10PM +0100

Just implemented FAST sub-pixel text rendering in my OpenGL C++ GUI/game
library "neoGFX".
 
Screenshot:
 
http://neogfx.org/temp/subpixel3.png
 
/Flibble
Jerry Stuckle <jstucklex@attglobal.net>: Jul 27 04:22PM -0400

On 7/27/2016 12:23 PM, Mr Flibble wrote:
> implementation in one of its header files that you included (either
> directly or indirectly) before your header file.
 
> /Flibble
 
Weasel response. Show a specific example where it DOES fail.
 
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Jul 27 04:23PM -0400

On 7/27/2016 12:26 PM, Mr Flibble wrote:
> header file was included before the implementation's header file was
> included (either directly or indirectly).
 
> /Flibble
 
Which is why it's a good idea to use a header guard related to the file
name. But you missed that part - because you don't read so well.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Jul 27 04:49PM -0400

On 7/27/2016 3:01 PM, Paavo Helde wrote:
 
> PeopleConcert concert;
> concert.Organize();
 
> }
 
Two things.
 
First of all, that's not the header guard I said.
 
Second of all, I don't have MSVC 2103 (does anyone? That's not for
another 87 years), but your code compiles just fine with gcc 5.4.0.
Either the code you presented is not what you compiled (maybe you have
another PeopleConcert.h?), or you have a problem with your compiler.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
David Brown <david.brown@hesbynett.no>: Jul 28 10:37AM +0200

On 27/07/16 22:49, Jerry Stuckle wrote:
> another 87 years), but your code compiles just fine with gcc 5.4.0.
> Either the code you presented is not what you compiled (maybe you have
> another PeopleConcert.h?), or you have a problem with your compiler.
 
Whoosh! That's the sound Paavo's example makes as it passes completely
over your head.
 
Since this seems too subtle for you to follow, I'll explain it in small
steps.
 
The standards (C and C++) make certain classes of identifiers
"reserved". This includes identifiers that start with two underscores,
and identifiers that start with one underscore then a capital letter.
Some of these are reserved for future language changes, others are
reserved for the implementation.
 
It is good programming practice to take this into account when choosing
your own identifiers.
 
"Why?", I hear you ask (since you clearly don't understand at the
moment). Avoiding reserved identifiers in your own code means your
identifiers won't crash with reserved identifiers in a different or
future compiler. Similarly, implementations avoid non-reserved
identifiers to avoid crashes with the user code.
 
So you don't avoid using an identifier like "_PPLCONCRT_H" just because
it might cause trouble /now/, you avoid using it because it might cause
trouble in the future. A future C compiler - such as MSVC 2103 - might
use that as an include guard in one of its own implementation-supplied
header files.
 
Do you see the point now?
Jerry Stuckle <jstucklex@attglobal.net>: Jul 28 01:53PM -0400

On 7/28/2016 4:37 AM, David Brown wrote:
> use that as an include guard in one of its own implementation-supplied
> header files.
 
> Do you see the point now?
 
Whoosh. You completely missed my response.
 
No, I didn't miss Paavo's comment. I just pointed out he has a problem
in either his code or his compiler, and that he didn't use the example I
did. Nothing more, nothing less.
 
But you're too dense to understand that.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jul 28 07:06PM +0100

Frank Tetzel <s1445051@mail.zih.tu-dresden.de>: Jul 28 01:48AM +0200

Hello,
 
does anybody know of any library transforming a regular expression as
a string to an equivalent automaton (minimized DFA preferable)? I don't
want to do string matching directly, so most of the regex library
can't really help me. I want access to the automaton. Does anybody know
of a library or framework providing this?
 
Regards,
Frank
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jul 28 01:18AM +0100

On 28/07/2016 00:48, Frank Tetzel wrote:
> want to do string matching directly, so most of the regex library
> can't really help me. I want access to the automaton. Does anybody know
> of a library or framework providing this?
 
Sausages.
 
Seriously though, sausages.
 
Really seriously though don't get hung up finite state machines; they
are usually a generalization on something that doesn't need generalizing.*
 
/Flibble
 
* Just finished my third double vodka.
Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid>: Jul 28 10:31AM +0200

> want to do string matching directly, so most of the regex library
> can't really help me. I want access to the automaton. Does anybody know
> of a library or framework providing this?
 
Some of my students have used
http://hackingoff.com/compilers/regular-expression-to-nfa-dfa
I don't know if its available for download.
 
But then, it is not a bad exercise to do it yourself... Especially if
you have special requirements on characters, etc.
 
(This has little to no relation to C++, you may get more help from
comp.theory or comp.compilers I guess.)
 
-- Alain.
Frank Tetzel <s1445051@mail.zih.tu-dresden.de>: Jul 28 05:16PM +0200


> Some of my students have used
> http://hackingoff.com/compilers/regular-expression-to-nfa-dfa
> I don't know if its available for download.
 
It doesn't look like there's a download somewhere but it's a nice
visualization. Thanks.
 
 
> But then, it is not a bad exercise to do it yourself... Especially if
> you have special requirements on characters, etc.
 
Yeah, i probably have to do that. For my current project it would just
be a nice-to-have, a simple string interface. Let's see if i find the
time for that. A nice description:
https://swtch.com/~rsc/regexp/regexp1.html
 
 
> (This has little to no relation to C++, you may get more help from
> comp.theory or comp.compilers I guess.)
 
I might ask there when i have more specific questions during
implementing it. Thanks for the pointers.
 
Regards,
Frank
Ramine <ramine@1.1>: Jul 28 01:54PM -0400

On 7/27/2016 7:48 PM, Frank Tetzel wrote:
> of a library or framework providing this?
 
> Regards,
> Frank
 
I have worked with the following program, and it works great:
 
http://max99x.com/school/automata-editor
 
 
Thank you,
Amine Moulay Ramdane.
bleachbot <bleachbot@httrack.com>: Jul 28 07:52PM +0200

jarausch@skynet.be: Jul 28 07:00AM -0700

Hi,
 
the following code should compile according to the standard (library).
 
#include <iostream>
using std::ios;
#include <fstream>
 
 
 
int main() {
int offset = 0;
ios::seek_dir org;
org= ios::beg;
std::ifstream input("Test.txt");
input.seekg(offset, org);
return 0;
}
 
 
g++ (5.4.0) gives the following error messages:
 
IOS_Test.C: In function 'int main()':
IOS_Test.C:12:26: error: invalid conversion from 'std::ios_base::seek_dir {aka int}' to
'std::ios_base::seekdir {aka std::_Ios_Seekdir}' [-fpermissive]
input.seekg(offset, org);
^
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5/iostream:40:0,
from IOS_Test.C:1:
/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5/istream:602:7: note:
initializing argument 2 of 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::seekg
(std::basic_istream<_CharT, _Traits>::off_type, std::ios_base::seekdir)
[with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT,
_Traits>::off_type = long int; std::ios_base::seekdir = std::_Ios_Seekdir]'
seekg(off_type, ios_base::seekdir);
 
Is this a bug or what am I missing?
 
Many thanks for a hint,
Helmut
"Öö Tiib" <ootiib@hot.ee>: Jul 28 10:21AM -0700

> Hi,
 
> the following code should compile according to the standard (library).
 
What standard library? Cite, link, quote?
 
> _Traits>::off_type = long int; std::ios_base::seekdir = std::_Ios_Seekdir]'
> seekg(off_type, ios_base::seekdir);
 
> Is this a bug or what am I missing?
 
Yes it is your bug and compiler complains cleanly. All you need is to
read a bit of docks. I can highlight the points: That 'ios_base::beg'
is of type 'ios_base::seekdir'. That 'ios_base::seek_dir' that you use
is deprecated member type and compatibility with 'ios_base::seekdir'
is nowhere required. See yourself:
http://en.cppreference.com/w/cpp/io/ios_base
jarausch@skynet.be: Jul 28 10:35AM -0700

Many thanks!
I didn't realize that there are two different type(def)s:
seekdir and seek_dir.
 
Helmut.
Will Watts <ais@no.spam.please.cix.co.uk>: Jul 28 06:05PM +0100

In article <kamdnZFwo7Qm0QjKnZ2dnUU7-e-dnZ2d@giganews.com>, Mr Flibble
wrote:
> In case you were wondering Mr Flibble is a minor character from the UK
> comedy sci-fi TV series Red Dwarf.
 
A favourite episode, I think. The one where Lister contracts a luck
virus.
 
Will@AIS
Jerry Stuckle <jstucklex@attglobal.net>: Jul 27 04:26PM -0400

On 7/27/2016 3:51 PM, Daniel wrote:
 
> Actually, the affectionate, pet form for Flibble is "Flibbie", not "Fibbie."
 
> Just trying to be helpful,
> Daniel
 
Ah, thank you, Daniel. I appreciate the correction.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: