comp.lang.c++@googlegroups.com | Google Groups | ![]() |
Unsure why you received this message? You previously subscribed to digests from this group, but we haven't been sending them for a while. We fixed that, but if you don't want to get these messages, send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
- Are raw pointers acceptable when used only internally within a class implementation? - 3 Updates
- Help with operator overloading definition and (possibly) link problems - 3 Updates
- copying from an input stream into a string - 4 Updates
- initializer list - 7 Updates
- "JetBrains CLion C++ IDE First Impressions" - 5 Updates
- "C++14 Is Here: Summary of New Features" - 1 Update
- copying from an input stream into a string - 1 Update
kurt krueckeberg <kkruecke@gmail.com>: Sep 11 03:04PM -0700 I have implemented a 2 3 4 tree using raw pointers. The Node234 class has a Node234 *parent member variable. Is there any reason to use managed pointer is the raw pointers are only used internally and never exposed to clients. The class looks like this. shared_ptr<Node234> seems like needless overhead? template<typename K> class Tree234 { protected: class Node234; // forward declaration of nested class. Node234 *root; void split(Node234 *node); // called during insert to split 4-nodes void DestroyTree(Node234 *root); Node234 *convertTwoNode(Node234 *node); Node234 *fuseSiblings(Node234 *parent, int node2_id, int sibling_id); Node234 *doRotation(Node234 *parent, int node2_id, int sibling_id); // snip... class Node234 { private: friend class Tree234<K>; static int MAX_KEYS; Node234 *parent; int totalItems; /* If 1, two node; if 2, three node; if 3, four node. */ K keys[3]; Node234 *children[4]; Node234(K small); Node234(K small, K larger); Node234(K small, K middle, K large); void connectChild(int childNum, Node234 *child); bool searchNode(K key, int& index, Node234 *&next); Node234 *disconnectChild(int child_index); void insertChild(int childNum, Node234 *pChild); // snip ... public: int getTotalItems() const; bool isLeaf() const; //.. snip... }; public: Tree234() { root = nullptr; } ~Tree234(); bool search(K key); template<typename Functor> void traverse(Functor f); template<typename Functor> void postOrderTraverse(Functor f); void insert(K key); bool remove(K key); }; |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Sep 11 11:12PM +0100 On 11/09/2014 23:04, kurt krueckeberg wrote: > Is there any reason to use managed pointer is the raw pointers are only used internally and never exposed to clients. No. /Flibble |
Christopher Pisz <nospam@notanaddress.com>: Sep 11 05:18PM -0500 On 9/11/2014 5:12 PM, Mr Flibble wrote: >> only used internally and never exposed to clients. > No. > /Flibble I agree. Do not use shared pointers or any ref counting types just because they exist. I've encountered as many circular reference leaks as I have leaks from raw pointers. Either way, understand and verify when memory is allocated and when memory is released, even if using a ref counting or shared pointer, verify it actually got released. |
Noob <nope@nono.com>: Sep 11 04:30PM -0300 Hi there. I'm performing my first experiments in C++ and I'm having a bit of trouble when trying put the definition of an operator overloading in a separate file. I understand the example is a bit silly but anyways. The following code when written in a single file will work and output the desired results: $cat foo_main.cpp #include <iostream> #include <array> template<typename T, std::size_t SIZE> std::array<T,SIZE> operator+(const std::array<T,SIZE>& a, const std::array<T,SIZE>& b) { std::array<T,SIZE> result; for(unsigned int i = 0; i < a.size(); ++i) { result[i] = a[i] + b[i]; } return result; } int main() { std::array<double, 10> arr1, arr2, arr3; for(unsigned int i = 0; i < arr1.size(); i++) { arr1[i] = i; arr2[i] = 2*i; } arr3 = arr1 + arr2; for(unsigned int i = 0; i < arr3.size(); ++i) { std::cout << arr3[i] << std::endl; } } $ g++ --version g++ (Debian 4.7.2-5) 4.7.2 $g++ -std=c++11 foo_main.cpp && ./a.out 0 3 6 9 12 15 18 21 24 27 Now let $cat foo.h #ifndef FOO_H_INCLUDED #define FOO_H_INCLUDED #include <array> template<typename T, std::size_t SIZE> std::array<T,SIZE> operator+(const std::array<T,SIZE>& a, const std::array<T,SIZE>& b); $ cat foo.cpp #include <array> #include "foo.h" template<typename T, std::size_t SIZE> std::array<T,SIZE> operator+(const std::array<T,SIZE>& a, const std::array<T,SIZE>& b) { std::array<T,SIZE> result; for(unsigned int i = 0; i < a.size(); ++i) { result[i] = a[i] + b[i]; } return result; } $ cat main_split.cpp #include "foo.h" #include <iostream> #include <array> int main() { std::array<double, 10> arr1, arr2, arr3; for(unsigned int i = 0; i < arr1.size(); i++) { arr1[i] = i; arr2[i] = 2*i; } arr3 = arr1 + arr2; for(unsigned int i = 0; i < arr3.size(); ++i) { std::cout << arr3[i] << std::endl; } } $g++ -std=c++11 main_split.cpp foo.cpp /tmp/cczMGm79.o: In function `main': main_split.cpp:(.text+0xdc): undefined reference to `std::array<double, 10ul> operator+<double, 10ul>(std::array<double, 10ul> const&, std::array<double, 10ul> const&)' collect2: error: ld returned 1 exit status I don't know what is the problem. I can compile a similar program declaring simple functions in separate files but not this particular case. Thanks in advance for any help. |
Paavo Helde <myfirstname@osa.pri.ee>: Sep 11 03:12PM -0500 > I'm performing my first experiments in C++ and I'm having a > bit of trouble when trying put the definition of an operator > overloading in a separate file. See http://www.parashift.com/c++-faq/templates-defn-vs-decl.html Actually, once there, better read through the whole FAQ. Cheers Paavo |
Noob <nope@nono.com>: Sep 11 06:03PM -0300 On 09/11/2014 05:12 PM, Paavo Helde wrote: > Actually, once there, better read through the whole FAQ. > Cheers > Paavo Thank you very much. There's -a lot- of useful information there. In my case, would you recommend me to move the definition of the template to the header file or to do the second solution shown here: http://www.parashift.com/c++-faq/separate-template-fn-defn-from-decl.html The former seems easy enough but I wouldn't like to make a habit of it if it happens to be a source of future complications. The latter solution implies in telling the compiler which instantiations I'll actually need (right?) but I'm not sure how to deal with it in my case without explicitly declaring a SIZE. Thanks again. |
woodbrian77@gmail.com: Sep 10 07:02PM -0700 On Wednesday, September 10, 2014 1:18:56 PM UTC-5, Victor Bazarov wrote: > Or perhaps by means of one of c-tors. Standard string has a constructor > from two input iterators (see 21.4.2/14), so if you can convert the > positions into iterators, you could simply construct the string from them. I use this constructor sometimes: string (const char* s, size_t n); Copies the first n characters from the array of characters pointed by s. I got the reference info from cplusplus.com Brian Ebenezer Enterprises - In G-d we trust. http://webEbenezer.net |
Victor Bazarov <v.bazarov@comcast.invalid>: Sep 11 08:50AM -0400 On 9/11/2014 7:58 AM, Stefan Ram wrote: > The constructor+iterator combination is elegant, but the fastest > way is to get the filesize and then pre-allocate a buffer. > Getting the filesize is difficult. [..] Who said it was a file? V -- I do not respond to top-posted replies, please don't ask |
Luca Risolia <luca.risolia@linux-projects.org>: Sep 11 07:18PM +0200 glen stark wrote: > I can think of a number of ways to do this, but I don't like any of > them. What do you think is the most elegant way to do this? > Thanks, Try this: http://www.linux-projects.org/listing/cpp_solutions/20.5/main.cpp Below is the code: #include <string> #include <iterator> #include <iostream> #include <algorithm> #include <vector> namespace mystd { template<class Cont> class back_insert_iterator; /* * Base class for all the back_insert_iterator's. It requires * a back_insert_iterator class as template argument. */ template<class Cont, class Derived = back_insert_iterator<Cont> > class back_insert_iterator_base : public std::iterator<std::output_iterator_tag, void, void, void, void> { protected: Cont& container; explicit back_insert_iterator_base(Cont& c) : container(c) { } public: typedef Cont container_type; Derived& operator=(typename container_type::const_reference v) { container.push_back(v); return *(static_cast<Derived*> (this)); } Derived& operator++() { return *(static_cast<Derived*> (this)); } Derived& operator++(int) { return *(static_cast<Derived*> (this)); } Derived& operator*() { return *(static_cast<Derived*> (this)); } }; /* * Generic back_insert_iterator for any container */ template<class Cont> class back_insert_iterator : public back_insert_iterator_base<Cont> { public: explicit back_insert_iterator(Cont& c) : back_insert_iterator_base<Cont> (c) { } using back_insert_iterator_base<Cont>::operator =; }; /* * Specialized class for a basic_string's: * this class adds one more operator=() implementing string concatenation */ template<class Ch, class Tr, class A> class back_insert_iterator<std::basic_string<Ch, Tr, A> > : public back_insert_iterator_base<std::basic_string<Ch, Tr, A> > { public: explicit back_insert_iterator(std::basic_string<Ch, Tr, A>& c) : back_insert_iterator_base<std::basic_string<Ch, Tr, A> > (c) { } using back_insert_iterator_base<std::basic_string<Ch, Tr, A> >::operator =; back_insert_iterator& operator=(const std::basic_string<Ch, Tr, A> & s) { back_insert_iterator_base<std::basic_string<Ch, Tr, A> >::container.append(s); return *this; } }; /* * This is convenience function. It returns a back insert iterator * for a container without requiring us to specify any template argument. */ template <class Cont> back_insert_iterator<Cont> back_inserter(Cont& c) { return back_insert_iterator<Cont > (c); } } int main(int argc, char** argv) { // Two examples using namespace std; typedef basic_string<char> String; vector<String > v; copy(std::istream_iterator<String > (std::cin), std::istream_iterator<String > (), mystd::back_inserter(v)); String s; copy(v.begin(), v.end(), mystd::back_inserter(s)); cout << s; return 0; } |
Paavo Helde <myfirstname@osa.pri.ee>: Sep 11 03:10PM -0500 ram@zedat.fu-berlin.de (Stefan Ram) wrote in news:slurp-20140911135058 >>them. What do you think is the most elegant way to do this? > The constructor+iterator combination is elegant, but the fastest > way is to get the filesize and then pre-allocate a buffer. If it is a file, then the fastest way to get it into memory is to use memory mapping. Some might claim this is also the most elegant way ;-) Cheers Paavo |
Christopher Pisz <nospam@notanaddress.com>: Sep 11 10:58AM -0500 I read that we could use the following syntax in C++11 with standard containers. This is not working for me in msvc 2012. Is it a compiler specific problem, or did I misunderstand how to do this? std::vector<std::string> test = {"foo","bar"}; I'd like to set up a static const at the top of my cpp to define a collection of strings. |
Victor Bazarov <v.bazarov@comcast.invalid>: Sep 11 12:05PM -0400 On 9/11/2014 11:58 AM, Christopher Pisz wrote: > std::vector<std::string> test = {"foo","bar"}; > I'd like to set up a static const at the top of my cpp to define a > collection of strings. a) Drop the '='. b) VC++ 2012 doesn't support that syntax. Get VC++ 2013. V -- I do not respond to top-posted replies, please don't ask |
Lynn McGuire <lmc@winsim.com>: Sep 11 12:16PM -0500 On 9/11/2014 10:58 AM, Christopher Pisz wrote: > compiler specific problem, or did I misunderstand how to do this? > std::vector<std::string> test = {"foo","bar"}; > I'd like to set up a static const at the top of my cpp to define a collection of strings. I put this in my software about 15 years ago. Our software was originally written in smalltalk and had the concept of tuples well embedded in it. Works well but the language lawyers hate it with a passion: // try to model a tuple somewhat but with rigorous type checking vector <string> tupleString () { vector <string> aVectorOfstrings (0); return aVectorOfstrings; } vector <string> tupleString (string string1) { vector <string> aVectorOfstrings (1); aVectorOfstrings [0] = string1; return aVectorOfstrings; } vector <string> tupleString (string string1, string string2) { vector <string> aVectorOfstrings (2); aVectorOfstrings [0] = string1; aVectorOfstrings [1] = string2; return aVectorOfstrings; } And so and so forth. I have all the way up to 69 strings: vector <string> tupleString (string string1, string string2, string string3, string string4, string string5, string string6, string string7, string string8, string string9, string string10, string string11, string string12, string string13, string string14, string string15, string string16, string string17, string string18, string string19, string string20, string string21, string string22, string string23, string string24, string string25, string string26, string string27, string string28, string string29, string string30, string string31, string string32, string string33, string string34, string string35, string string36, string string37, string string38, string string39, string string40, string string41, string string42, string string43, string string44, string string45, string string46, string string47, string string48, string string49, string string50, string string51, string string52, string string53, string string54, string string55, string string56, string string57, string string58, string string59, string string60, string string61, string string62, string string63, string string64, string string65, string string66, string string67, string string68, string string69) { vector <string> aVectorOfstrings (69); aVectorOfstrings [0] = string1; aVectorOfstrings [1] = string2; aVectorOfstrings [2] = string3; aVectorOfstrings [3] = string4; aVectorOfstrings [4] = string5; aVectorOfstrings [5] = string6; aVectorOfstrings [6] = string7; aVectorOfstrings [7] = string8; aVectorOfstrings [8] = string9; aVectorOfstrings [9] = string10; aVectorOfstrings [10] = string11; aVectorOfstrings [11] = string12; aVectorOfstrings [12] = string13; aVectorOfstrings [13] = string14; aVectorOfstrings [14] = string15; aVectorOfstrings [15] = string16; aVectorOfstrings [16] = string17; aVectorOfstrings [17] = string18; aVectorOfstrings [18] = string19; aVectorOfstrings [19] = string20; aVectorOfstrings [20] = string21; aVectorOfstrings [21] = string22; aVectorOfstrings [22] = string23; aVectorOfstrings [23] = string24; aVectorOfstrings [24] = string25; aVectorOfstrings [25] = string26; aVectorOfstrings [26] = string27; aVectorOfstrings [27] = string28; aVectorOfstrings [28] = string29; aVectorOfstrings [29] = string30; aVectorOfstrings [30] = string31; aVectorOfstrings [31] = string32; aVectorOfstrings [32] = string33; aVectorOfstrings [33] = string34; aVectorOfstrings [34] = string35; aVectorOfstrings [35] = string36; aVectorOfstrings [36] = string37; aVectorOfstrings [37] = string38; aVectorOfstrings [38] = string39; aVectorOfstrings [39] = string40; aVectorOfstrings [40] = string41; aVectorOfstrings [41] = string42; aVectorOfstrings [42] = string43; aVectorOfstrings [43] = string44; aVectorOfstrings [44] = string45; aVectorOfstrings [45] = string46; aVectorOfstrings [46] = string47; aVectorOfstrings [47] = string48; aVectorOfstrings [48] = string49; aVectorOfstrings [49] = string50; aVectorOfstrings [50] = string51; aVectorOfstrings [51] = string52; aVectorOfstrings [52] = string53; aVectorOfstrings [53] = string54; aVectorOfstrings [54] = string55; aVectorOfstrings [55] = string56; aVectorOfstrings [56] = string57; aVectorOfstrings [57] = string58; aVectorOfstrings [58] = string59; aVectorOfstrings [59] = string60; aVectorOfstrings [60] = string61; aVectorOfstrings [61] = string62; aVectorOfstrings [62] = string63; aVectorOfstrings [63] = string64; aVectorOfstrings [64] = string65; aVectorOfstrings [65] = string66; aVectorOfstrings [66] = string67; aVectorOfstrings [67] = string68; aVectorOfstrings [68] = string69; return aVectorOfstrings; } I will post the rest and the prototypes if needful. Lynn |
Christopher Pisz <nospam@notanaddress.com>: Sep 11 12:49PM -0500 On 9/11/2014 12:16 PM, Lynn McGuire wrote: > } > I will post the rest and the prototypes if needful. > Lynn Time to fire up the Notepad++ macros! Thanks, I'll give it a shot. |
Victor Bazarov <v.bazarov@comcast.invalid>: Sep 11 02:14PM -0400 On 9/11/2014 1:49 PM, Christopher Pisz wrote: >> I will post the rest and the prototypes if needful. >> Lynn > Time to fire up the Notepad++ macros! Thanks, I'll give it a shot. You're probably better off using intermediate arrays for that: string _4v_[] = { "foo", "bar" }; // or more vector<string> test(_4v_, _4v_ + sizeof(_4v_)/sizeof(*_4v_)); V -- I do not respond to top-posted replies, please don't ask |
Lynn McGuire <lmc@winsim.com>: Sep 11 02:59PM -0500 >> I will post the rest and the prototypes if needful. >> Lynn > Time to fire up the Notepad++ macros! Thanks, I'll give it a shot. tuple.h file: // tuple.h // 09/28/09 Lynn McGuire add tuple with 60 items // 10/21/09 Lynn McGuire add tupleString with 69 items // 11/13/09 Lynn McGuire add std:: namespace declaration // 11/16/10 Lynn McGuire add more tupleStrings #ifndef __tuple_h__ #define __tuple_h__ // NOTE: tuple must be an base method for it to work on outside methods std::vector <int> tuple (); std::vector <int> tuple (int int1); std::vector <int> tuple (int int1, int int2); std::vector <int> tuple (int int1, int int2, int int3); std::vector <int> tuple (int int1, int int2, int int3, int int4); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23, int int24); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23, int int24, int int25); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23, int int24, int int25, int int26); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23, int int24, int int25, int int26, int int27); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23, int int24, int int25, int int26, int int27, int int28); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23, int int24, int int25, int int26, int int27, int int28, int int29); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23, int int24, int int25, int int26, int int27, int int28, int int29, int int30); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23, int int24, int int25, int int26, int int27, int int28, int int29, int int30, int int31); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23, int int24, int int25, int int26, int int27, int int28, int int29, int int30, int int31, int int32); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23, int int24, int int25, int int26, int int27, int int28, int int29, int int30, int int31, int int32, int int33); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23, int int24, int int25, int int26, int int27, int int28, int int29, int int30, int int31, int int32, int int33, int int34); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23, int int24, int int25, int int26, int int27, int int28, int int29, int int30, int int31, int int32, int int33, int int34, int int35); std::vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23, int int24, int int25, int int26, int int27, int int28, int int29, int int30, int int31, int int32, int int33, int int34, int int35, int int36, int int37, int int38, int int39, int int40, int int41, int int42, int int43, int int44, int int45, int int46, int int47, int int48, int int49, int int50, int int51, int int52, int int53, int int54, int int55, int int56, int int57, int int58, int int59, int int60); std::vector <std::string> tupleString (); std::vector <std::string> tupleString (std::string string1); std::vector <std::string> tupleString (std::string string1, std::string string2); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6, std::string string7); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6, std::string string7, std::string string8); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6, std::string string7, std::string string8, std::string string9); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6, std::string string7, std::string string8, std::string string9, std::string string10); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6, std::string string7, std::string string8, std::string string9, std::string string10, std::string string11); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6, std::string string7, std::string string8, std::string string9, std::string string10, std::string string11, std::string string12); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6, std::string string7, std::string string8, std::string string9, std::string string10, std::string string11, std::string string12, std::string string13); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6, std::string string7, std::string string8, std::string string9, std::string string10, std::string string11, std::string string12, std::string string13, std::string string14); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6, std::string string7, std::string string8, std::string string9, std::string string10, std::string string11, std::string string12, std::string string13, std::string string14, std::string string15); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6, std::string string7, std::string string8, std::string string9, std::string string10, std::string string11, std::string string12, std::string string13, std::string string14, std::string string15, std::string string16); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6, std::string string7, std::string string8, std::string string9, std::string string10, std::string string11, std::string string12, std::string string13, std::string string14, std::string string15, std::string string16, std::string string17); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6, std::string string7, std::string string8, std::string string9, std::string string10, std::string string11, std::string string12, std::string string13, std::string string14, std::string string15, std::string string16, std::string string17, std::string string18); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6, std::string string7, std::string string8, std::string string9, std::string string10, std::string string11, std::string string12, std::string string13, std::string string14, std::string string15, std::string string16, std::string string17, std::string string18, std::string string19); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6, std::string string7, std::string string8, std::string string9, std::string string10, std::string string11, std::string string12, std::string string13, std::string string14, std::string string15, std::string string16, std::string string17, std::string string18, std::string string19, std::string string20); std::vector <std::string> tupleString (std::string string1, std::string string2, std::string string3, std::string string4, std::string string5, std::string string6, std::string string7, std::string string8, std::string string9, std::string string10, std::string string11, std::string string12, std::string string13, std::string string14, std::string string15, std::string string16, std::string string17, std::string string18, std::string string19, std::string |
Lynn McGuire <lmc@winsim.com>: Sep 11 03:01PM -0500 >> I will post the rest and the prototypes if needful. >> Lynn > Time to fire up the Notepad++ macros! Thanks, I'll give it a shot. tuple.cpp file: // tuple.cpp #include "tuple.h" // try to model a tuple somewhat but with rigorous type checking // 11/25/08 Lynn McGuire fix tupleString(18) to have 18 entries instead // of 20 entries // 09/28/09 Lynn McGuire add tuple with 60 items // 11/16/10 Lynn McGuire add more tupleStrings vector <int> tuple () { vector <int> aVectorOfInts (0); return aVectorOfInts; } vector <int> tuple (int int1) { vector <int> aVectorOfInts (1); aVectorOfInts [0] = int1; return aVectorOfInts; } vector <int> tuple (int int1, int int2) { vector <int> aVectorOfInts (2); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3) { vector <int> aVectorOfInts (3); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4) { vector <int> aVectorOfInts (4); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5) { vector <int> aVectorOfInts (5); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6) { vector <int> aVectorOfInts (6); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7) { vector <int> aVectorOfInts (7); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8) { vector <int> aVectorOfInts (8); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9) { vector <int> aVectorOfInts (9); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10) { vector <int> aVectorOfInts (10); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11) { vector <int> aVectorOfInts (11); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; aVectorOfInts [10] = int11; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12) { vector <int> aVectorOfInts (12); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; aVectorOfInts [10] = int11; aVectorOfInts [11] = int12; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13) { vector <int> aVectorOfInts (13); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; aVectorOfInts [10] = int11; aVectorOfInts [11] = int12; aVectorOfInts [12] = int13; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14) { vector <int> aVectorOfInts (14); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; aVectorOfInts [10] = int11; aVectorOfInts [11] = int12; aVectorOfInts [12] = int13; aVectorOfInts [13] = int14; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15) { vector <int> aVectorOfInts (15); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; aVectorOfInts [10] = int11; aVectorOfInts [11] = int12; aVectorOfInts [12] = int13; aVectorOfInts [13] = int14; aVectorOfInts [14] = int15; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16) { vector <int> aVectorOfInts (16); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; aVectorOfInts [10] = int11; aVectorOfInts [11] = int12; aVectorOfInts [12] = int13; aVectorOfInts [13] = int14; aVectorOfInts [14] = int15; aVectorOfInts [15] = int16; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17) { vector <int> aVectorOfInts (17); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; aVectorOfInts [10] = int11; aVectorOfInts [11] = int12; aVectorOfInts [12] = int13; aVectorOfInts [13] = int14; aVectorOfInts [14] = int15; aVectorOfInts [15] = int16; aVectorOfInts [16] = int17; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18) { vector <int> aVectorOfInts (18); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; aVectorOfInts [10] = int11; aVectorOfInts [11] = int12; aVectorOfInts [12] = int13; aVectorOfInts [13] = int14; aVectorOfInts [14] = int15; aVectorOfInts [15] = int16; aVectorOfInts [16] = int17; aVectorOfInts [17] = int18; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19) { vector <int> aVectorOfInts (19); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; aVectorOfInts [10] = int11; aVectorOfInts [11] = int12; aVectorOfInts [12] = int13; aVectorOfInts [13] = int14; aVectorOfInts [14] = int15; aVectorOfInts [15] = int16; aVectorOfInts [16] = int17; aVectorOfInts [17] = int18; aVectorOfInts [18] = int19; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20) { vector <int> aVectorOfInts (20); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; aVectorOfInts [10] = int11; aVectorOfInts [11] = int12; aVectorOfInts [12] = int13; aVectorOfInts [13] = int14; aVectorOfInts [14] = int15; aVectorOfInts [15] = int16; aVectorOfInts [16] = int17; aVectorOfInts [17] = int18; aVectorOfInts [18] = int19; aVectorOfInts [19] = int20; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21) { vector <int> aVectorOfInts (21); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; aVectorOfInts [10] = int11; aVectorOfInts [11] = int12; aVectorOfInts [12] = int13; aVectorOfInts [13] = int14; aVectorOfInts [14] = int15; aVectorOfInts [15] = int16; aVectorOfInts [16] = int17; aVectorOfInts [17] = int18; aVectorOfInts [18] = int19; aVectorOfInts [19] = int20; aVectorOfInts [20] = int21; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22) { vector <int> aVectorOfInts (22); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; aVectorOfInts [10] = int11; aVectorOfInts [11] = int12; aVectorOfInts [12] = int13; aVectorOfInts [13] = int14; aVectorOfInts [14] = int15; aVectorOfInts [15] = int16; aVectorOfInts [16] = int17; aVectorOfInts [17] = int18; aVectorOfInts [18] = int19; aVectorOfInts [19] = int20; aVectorOfInts [20] = int21; aVectorOfInts [21] = int22; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23) { vector <int> aVectorOfInts (23); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; aVectorOfInts [10] = int11; aVectorOfInts [11] = int12; aVectorOfInts [12] = int13; aVectorOfInts [13] = int14; aVectorOfInts [14] = int15; aVectorOfInts [15] = int16; aVectorOfInts [16] = int17; aVectorOfInts [17] = int18; aVectorOfInts [18] = int19; aVectorOfInts [19] = int20; aVectorOfInts [20] = int21; aVectorOfInts [21] = int22; aVectorOfInts [22] = int23; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23, int int24) { vector <int> aVectorOfInts (24); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; aVectorOfInts [10] = int11; aVectorOfInts [11] = int12; aVectorOfInts [12] = int13; aVectorOfInts [13] = int14; aVectorOfInts [14] = int15; aVectorOfInts [15] = int16; aVectorOfInts [16] = int17; aVectorOfInts [17] = int18; aVectorOfInts [18] = int19; aVectorOfInts [19] = int20; aVectorOfInts [20] = int21; aVectorOfInts [21] = int22; aVectorOfInts [22] = int23; aVectorOfInts [23] = int24; return aVectorOfInts; } vector <int> tuple (int int1, int int2, int int3, int int4, int int5, int int6, int int7, int int8, int int9, int int10, int int11, int int12, int int13, int int14, int int15, int int16, int int17, int int18, int int19, int int20, int int21, int int22, int int23, int int24, int int25) { vector <int> aVectorOfInts (25); aVectorOfInts [0] = int1; aVectorOfInts [1] = int2; aVectorOfInts [2] = int3; aVectorOfInts [3] = int4; aVectorOfInts [4] = int5; aVectorOfInts [5] = int6; aVectorOfInts [6] = int7; aVectorOfInts [7] = int8; aVectorOfInts [8] = int9; aVectorOfInts [9] = int10; aVectorOfInts [10] = int11; aVectorOfInts [11] = int12; aVectorOfInts [12] = int13; aVectorOfInts [13] = int14; aVectorOfInts [14] = int15; aVectorOfInts [15] = int16; aVectorOfInts [16] = int17; aVectorOfInts [17] = int18; aVectorOfInts [18] = int19; aVectorOfInts [19] = int20; aVectorOfInts [20] = int21; aVectorOfInts [21] = int22; aVectorOfInts [22] = int23; aVectorOfInts [23] = int24; aVectorOfInts [24] = int25; |
Jorgen Grahn <grahn+nntp@snipabacken.se>: Sep 11 11:50AM On Wed, 2014-09-10, Stefan Ram wrote: >>system? > The Unix command line is the ultimate IDE IMHO. > You get: man pages, ctags, valgrind, ... you name it. And it's easily extendable and programmable ... /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
Stuart <DerTopper@web.de>: Sep 11 02:30PM +0200 On 09/11/14, Ian Collins wrote: [snip] > Are there any IDEs (if you exclude emacs) that don't require a windowing > system? I once read the following comment, but I cannot find the original source (http://c2.com/cgi/wiki?EmacsAsOperatingSystem comes close, but it was a different site). <<Emacs is not a text editor. It has so many features that the closest you can call it is an operating system. Sadly, it is not a "real" OS because it lacks a simple and usable text editor ... >> SCNR, Stuart |
SG <s.gesemann@gmail.com>: Sep 11 05:39AM -0700 On Thursday, September 11, 2014 1:50:26 PM UTC+2, Jorgen Grahn wrote: > > The Unix command line is the ultimate IDE IMHO. > > You get: man pages, ctags, valgrind, ... you name it. > And it's easily extendable and programmable ... The problem is that one needs to be aware of all the tools, plugins and how to set them up to work together nicely. I'm sure this could be as convenient (or even more convenient) as popular IDEs. But it probably takes more time to learn compared to a single, well- integrated application. But maybe it's just me not having come across a nice article explaining how to setup editor X, compiler Y, debugger Z and accompanioning tools/plugins for language L. Cheers! sg |
Sam <sam@email-scan.com>: Sep 11 07:42AM -0500 Ian Collins writes: >> have to be running a windowing system. > Are there any IDEs (if you exclude emacs) that don't require a windowing > system? emacs, of course. |
Koneko <Koneko@idontwantspamfrom.net>: Sep 11 05:27PM +0300 Ian Collins wrote: > Are there any IDEs (if you exclude emacs) that don't require a windowing > system? ♪ Vim! Vim! Vim! Is a win for you. ♪♪ Install Vundle and go crazy. lol https://github.com/gmarik/Vundle.vim -- Koneko |
glen stark <g.a.stark@gmail.com>: Sep 11 01:29PM > one of the purposes of that keyword. Does it allow for easier reading > of the code? I don't know, depends on whom you ask. But I am not > arguing about that either. It may be my wording could be better, I'll put some thought into it. What I wanted to convey was that it's possible to imagine a case where auto saves you some effort typing, but makes the code less readable. This is a bad usage of auto. On the other hand, it may make the code more readable, an obvious example being using auto declare an iterator. This is good usage of auto. |
ram@zedat.fu-berlin.de (Stefan Ram): Sep 11 11:58AM >I can think of a number of ways to do this, but I don't like any of >them. What do you think is the most elegant way to do this? The constructor+iterator combination is elegant, but the fastest way is to get the filesize and then pre-allocate a buffer. Getting the filesize is difficult. First, one must take into account that it might change between obtaining the filesize and reading (think of a log file). Then, one can't just seek to the EOF: »seekg« and »tellg« seem to be defined using »pubseekoff« in ISO/IEC 14882:1998(E), which is defined in terms of »seekoff«, which is defined based on »::std::fseek«. ISO/IEC 9899:1990 explains about »::std::fseek«: »A binary stream need not meaningfully support fseek calls with a whence value of SEEK_END.« »::std::ate« requests a seek to the end of the file. Therefore, one can not assume that one will be able to obtain the size of a binary file in this way under every implementation of C++. One needs to look up the documentation of the implementation to find out whether it supports fseek calls with a whence value of SEEK_END in binary files. BTW: Has anyone actually ever seen such a document of an implementation where it specifies (all) the implementation- specified assertions? Where, for example, can one find this for gcc in the case of C++? A reasonable compromise might be copying the file to a string stream and then converting that string stream to a string. |
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:
Post a Comment