Search Results

Search found 575 results on 23 pages for 'aaa'.

Page 8/23 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Linked List Sorting with Strings In C

    - by user308583
    I have a struct, with a Name and a single Node called nextName It's a Singly Linked list, and my task is to create the list, based on alphabetical order of the strings. So iff i enter Joe Zolt and Arthur i should get my list structured as Joe Than Joe Zolt Than Arthur Joe Zolt I'm having trouble implementing the correct Algorithm, which would put the pointers in the right order. This is What I have as of Now. Temp would be the name the user just entered and is trying to put into the list, namebox is just a copy of my root, being the whole list if(temp != NULL) { struct node* namebox = root; while (namebox!=NULL && (strcmp((namebox)->name,temp->name) <= 0)) { namebox = namebox->nextName; printf("here"); } temp->nextName = namebox; namebox = temp; root = namebox; This Works right now, if i enter names like CCC BBB than AAA I Get Back AAA BBB CCC when i print But if i put AAA BBB CCC , When i print i only get CCC, it cuts the previous off.

    Read the article

  • arduino emacs development

    - by aaa
    hi. I would like to use emacs as a development environment for arduino programming. If you use emacs to program arduino, can you share some tips or links which you find useful. Is there official (or de facto) emacs mode? Also, am I going to miss something which is in arduino IDE if I use emacs exclusively? thank you .

    Read the article

  • Using java to send/receive different objects through UDP

    - by AAA
    Hello everyone, I am writing a program in Java where there are communications between two or more machines using UDP. My application sends objects after serializing them through the network to the other machine where it will be deserialized and dealt with it. I was successful in sending one kind of objects so far. My problem is that I want the sender to be able to send different kind of objects, and for the receiver to be able to receive them and cast them again to their appropriate types. However, since UDP allocates a byte buffer then receive the data into the buffer, it is impossible to cast or detect the type of the received object as different objects have different sizes. Is there is a way that I can use to send different kind of objects using UDP and then receive them at the other end? (I don't ask for code here, just some ideas) Thanks

    Read the article

  • C++ template meta-programming, number of member variables?

    - by aaa
    hello Is it possible in C++ to determine number of variables/fields in the generic class? for example // suppose I need metaclass number_members determines number of members struct example { int i, j; }; assert(number_members::value==2); I looked through mpl but could not find implementation thanks.

    Read the article

  • gcc segmentation fault compiling 20k file

    - by aaa
    hi. I have fairly large file, 20k lines long (auto generated). It has been compiling okay, but after adding new if/endif preprocessor block, I started getting gcc internal errors: segmentation fault. the code inside new preprocessor block is not being compiled, so I am not sure where the error is coming from. my only guess is memory, but as far as I can tell it does not exhaust computer memory. Any thoughts?

    Read the article

  • C++/boost generator module, feedback/critic please

    - by aaa
    hello. I wrote this generator, and I think to submit to boost people. Can you give me some feedback about it it basically allows to collapse multidimensional loops to flat multi-index queue. Loop can be boost lambda expressions. Main reason for doing this is to make parallel loops easier and separate algorithm from controlling structure (my fieldwork is computational chemistry where deep loops are common) 1 #ifndef _GENERATOR_HPP_ 2 #define _GENERATOR_HPP_ 3 4 #include <boost/array.hpp> 5 #include <boost/lambda/lambda.hpp> 6 #include <boost/noncopyable.hpp> 7 8 #include <boost/mpl/bool.hpp> 9 #include <boost/mpl/int.hpp> 10 #include <boost/mpl/for_each.hpp> 11 #include <boost/mpl/range_c.hpp> 12 #include <boost/mpl/vector.hpp> 13 #include <boost/mpl/transform.hpp> 14 #include <boost/mpl/erase.hpp> 15 16 #include <boost/fusion/include/vector.hpp> 17 #include <boost/fusion/include/for_each.hpp> 18 #include <boost/fusion/include/at_c.hpp> 19 #include <boost/fusion/mpl.hpp> 20 #include <boost/fusion/include/as_vector.hpp> 21 22 #include <memory> 23 24 /** 25 for loop generator which can use lambda expressions. 26 27 For example: 28 @code 29 using namespace generator; 30 using namespace boost::lambda; 31 make_for(N, N, range(bind(std::max<int>, _1, _2), N), range(_2, _3+1)); 32 // equivalent to pseudocode 33 // for l=0,N: for k=0,N: for j=max(l,k),N: for i=k,j 34 @endcode 35 36 If range is given as upper bound only, 37 lower bound is assumed to be default constructed 38 Lambda placeholders may only reference first three indices. 39 */ 40 41 namespace generator { 42 namespace detail { 43 44 using boost::lambda::constant_type; 45 using boost::lambda::constant; 46 47 /// lambda expression identity 48 template<class E, class enable = void> 49 struct lambda { 50 typedef E type; 51 }; 52 53 /// transform/construct constant lambda expression from non-lambda 54 template<class E> 55 struct lambda<E, typename boost::disable_if< 56 boost::lambda::is_lambda_functor<E> >::type> 57 { 58 struct constant : boost::lambda::constant_type<E>::type { 59 typedef typename boost::lambda::constant_type<E>::type base_type; 60 constant() : base_type(boost::lambda::constant(E())) {} 61 constant(const E &e) : base_type(boost::lambda::constant(e)) {} 62 }; 63 typedef constant type; 64 }; 65 66 /// range functor 67 template<class L, class U> 68 struct range_ { 69 typedef boost::array<int,4> index_type; 70 range_(U upper) : bounds_(typename lambda<L>::type(), upper) {} 71 range_(L lower, U upper) : bounds_(lower, upper) {} 72 73 template< typename T, size_t N> 74 T lower(const boost::array<T,N> &index) { 75 return bound<0>(index); 76 } 77 78 template< typename T, size_t N> 79 T upper(const boost::array<T,N> &index) { 80 return bound<1>(index); 81 } 82 83 private: 84 template<bool b, typename T> 85 T bound(const boost::array<T,1> &index) { 86 return (boost::fusion::at_c<b>(bounds_))(index[0]); 87 } 88 89 template<bool b, typename T> 90 T bound(const boost::array<T,2> &index) { 91 return (boost::fusion::at_c<b>(bounds_))(index[0], index[1]); 92 } 93 94 template<bool b, typename T, size_t N> 95 T bound(const boost::array<T,N> &index) { 96 using boost::fusion::at_c; 97 return (at_c<b>(bounds_))(index[0], index[1], index[2]); 98 } 99 100 boost::fusion::vector<typename lambda<L>::type, 101 typename lambda<U>::type> bounds_; 102 }; 103 104 template<typename T, size_t N> 105 struct for_base { 106 typedef boost::array<T,N> value_type; 107 virtual ~for_base() {} 108 virtual value_type next() = 0; 109 }; 110 111 /// N-index generator 112 template<typename T, size_t N, class R, class I> 113 struct for_ : for_base<T,N> { 114 typedef typename for_base<T,N>::value_type value_type; 115 typedef R range_tuple; 116 for_(const range_tuple &r) : r_(r), state_(true) { 117 boost::fusion::for_each(r_, initialize(index)); 118 } 119 /// @return new generator 120 for_* new_() { return new for_(r_); } 121 /// @return next index value and increment 122 value_type next() { 123 value_type next; 124 using namespace boost::lambda; 125 typename value_type::iterator n = next.begin(); 126 typename value_type::iterator i = index.begin(); 127 boost::mpl::for_each<I>(*(var(n))++ = var(i)[_1]); 128 129 state_ = advance<N>(r_, index); 130 return next; 131 } 132 /// @return false if out of bounds, true otherwise 133 operator bool() { return state_; } 134 135 private: 136 /// initialize indices 137 struct initialize { 138 value_type &index_; 139 mutable size_t i_; 140 initialize(value_type &index) : index_(index), i_(0) {} 141 template<class R_> void operator()(R_& r) const { 142 index_[i_++] = r.lower(index_); 143 } 144 }; 145 146 /// advance index[0:M) 147 template<size_t M> 148 struct advance { 149 /// stop recursion 150 struct stop { 151 stop(R r, value_type &index) {} 152 }; 153 /// advance index 154 /// @param r range tuple 155 /// @param index index array 156 advance(R &r, value_type &index) : index_(index), i_(0) { 157 namespace fusion = boost::fusion; 158 index[M-1] += 1; // increment index 159 fusion::for_each(r, *this); // update indices 160 state_ = index[M-1] >= fusion::at_c<M-1>(r).upper(index); 161 if (state_) { // out of bounds 162 typename boost::mpl::if_c<(M > 1), 163 advance<M-1>, stop>::type(r, index); 164 } 165 } 166 /// apply lower bound of range to index 167 template<typename R_> void operator()(R_& r) const { 168 if (i_ >= M) index_[i_] = r.lower(index_); 169 ++i_; 170 } 171 /// @return false if out of bounds, true otherwise 172 operator bool() { return state_; } 173 private: 174 value_type &index_; ///< index array reference 175 mutable size_t i_; ///< running index 176 bool state_; ///< out of bounds state 177 }; 178 179 value_type index; 180 range_tuple r_; 181 bool state_; 182 }; 183 184 185 /// polymorphic generator template base 186 template<typename T,size_t N> 187 struct For : boost::noncopyable { 188 typedef boost::array<T,N> value_type; 189 /// @return next index value and increment 190 value_type next() { return for_->next(); } 191 /// @return false if out of bounds, true otherwise 192 operator bool() const { return for_; } 193 protected: 194 /// reset smart pointer 195 void reset(for_base<T,N> *f) { for_.reset(f); } 196 std::auto_ptr<for_base<T,N> > for_; 197 }; 198 199 /// range [T,R) type 200 template<typename T, typename R> 201 struct range_type { 202 typedef range_<T,R> type; 203 }; 204 205 /// range identity specialization 206 template<typename T, class L, class U> 207 struct range_type<T, range_<L,U> > { 208 typedef range_<L,U> type; 209 }; 210 211 namespace fusion = boost::fusion; 212 namespace mpl = boost::mpl; 213 214 template<typename T, size_t N, class R1, class R2, class R3, class R4> 215 struct range_tuple { 216 // full range vector 217 typedef typename mpl::vector<R1,R2,R3,R4> v; 218 typedef typename mpl::end<v>::type end; 219 typedef typename mpl::advance_c<typename mpl::begin<v>::type, N>::type pos; 220 // [0:N) range vector 221 typedef typename mpl::erase<v, pos, end>::type t; 222 // transform into proper range fusion::vector 223 typedef typename fusion::result_of::as_vector< 224 typename mpl::transform<t,range_type<T, mpl::_1> >::type 225 >::type type; 226 }; 227 228 229 template<typename T, size_t N, 230 class R1, class R2, class R3, class R4, 231 class O> 232 struct for_type { 233 typedef typename range_tuple<T,N,R1,R2,R3,R4>::type range_tuple; 234 typedef for_<T, N, range_tuple, O> type; 235 }; 236 237 } // namespace detail 238 239 240 /// default index order, [0:N) 241 template<size_t N> 242 struct order { 243 typedef boost::mpl::range_c<size_t,0, N> type; 244 }; 245 246 /// N-loop generator, 0 < N <= 5 247 /// @tparam T index type 248 /// @tparam N number of indices/loops 249 /// @tparam R1,... range types 250 /// @tparam O index order 251 template<typename T, size_t N, 252 class R1, class R2 = void, class R3 = void, class R4 = void, 253 class O = typename order<N>::type> 254 struct for_ : detail::for_type<T, N, R1, R2, R3, R4, O>::type { 255 typedef typename detail::for_type<T, N, R1, R2, R3, R4, O>::type base_type; 256 typedef typename base_type::range_tuple range_tuple; 257 for_(const range_tuple &range) : base_type(range) {} 258 }; 259 260 /// loop range [L:U) 261 /// @tparam L lower bound type 262 /// @tparam U upper bound type 263 /// @return range 264 template<class L, class U> 265 detail::range_<L,U> range(L lower, U upper) { 266 return detail::range_<L,U>(lower, upper); 267 } 268 269 /// make 4-loop generator with specified index ordering 270 template<typename T, class R1, class R2, class R3, class R4, class O> 271 for_<T, 4, R1, R2, R3, R4, O> 272 make_for(R1 r1, R2 r2, R3 r3, R4 r4, const O&) { 273 typedef for_<T, 4, R1, R2, R3, R4, O> F; 274 return F(F::range_tuple(r1, r2, r3, r4)); 275 } 276 277 /// polymorphic generator template forward declaration 278 template<typename T,size_t N> 279 struct For; 280 281 /// polymorphic 4-loop generator 282 template<typename T> 283 struct For<T,4> : detail::For<T,4> { 284 /// generator with default index ordering 285 template<class R1, class R2, class R3, class R4> 286 For(R1 r1, R2 r2, R3 r3, R4 r4) { 287 this->reset(make_for<T>(r1, r2, r3, r4).new_()); 288 } 289 /// generator with specified index ordering 290 template<class R1, class R2, class R3, class R4, class O> 291 For(R1 r1, R2 r2, R3 r3, R4 r4, O o) { 292 this->reset(make_for<T>(r1, r2, r3, r4, o).new_()); 293 } 294 }; 295 296 } 297 298 299 #endif /* _GENERATOR_HPP_ */

    Read the article

  • Filtering most out of XML with XSL?

    - by Gnudiff
    I need to transform a lot of XML files (Fedora export) into a different kind of XML. Trying to do it with XSL stylesheets and checking with the msxsl transformer. Supposedly I have xml file like this (assuming there are actually other nodes inside AAA, OBJ, amd all other nodes), Source.XML: <DOC> <AAA> <STUFF>example</STUFF> <OBJ> <OBJVERS id="A1" CREATED="2008-02-18T13:28:08.245Z"/> <OBJVERS id="A2" CREATED="2008-02-19T10:42:41.965Z"/> <OBJVERS id="A13" CREATED="2009-03-16T12:43:11.703Z"/> </OBJ> </AAA> <FFF/> <GGG/> <DDD> <FILE /> </DDD> </DOC> Which I need to look something like this (Target.XML): <MYOBJ> <ELEM>contents of OBJVERS with the biggest id OR creation date (whichever is easier to do) go here</ELEM> <IMAGE> contents of <FILE> node go here</IMAGE> </MYOBJ> The main problem that I have is that since I am new to XSL (and for this particular task do not have enough time to learn it properly) is that I can't understand how to tell XSL processor not to process anything else, I keep getting output from , for example. Update: basically, I solved this problem meanwhile. I will post my own answer and close the question. Update2: OK, Andrew's answer works, too, so I am just accepting it. :)

    Read the article

  • C++ exceptions binary compatibility

    - by aaa
    hi. my project uses 2 different C++ compilers, g++ and nvcc (cuda compiler). I have noticed exception thrown from nvcc object files are not caught in g++ object files. are C++ exceptions supposed to be binary compatible in the same machine? what can cause such behavior?

    Read the article

  • ob_start() is partially capturing data

    - by AAA
    I am using the following code: PHP: // Generate Guid function NewGuid() { $s = strtoupper(uniqid(rand(),true)); $guidText = substr($s,0,8) . '-' . substr($s,8,4) . '-' . substr($s,12,4). '-' . substr($s,16,4). '-' . substr($s,20); return $guidText; } // End Generate Guid $Guid = NewGuid(); $alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'; function base_encode($num, $alphabet) { $base_count = strlen($alphabet); $encoded = ''; while ($num >= $base_count) { $div = $num/$base_count; $mod = ($num-($base_count*intval($div))); $encoded = $alphabet[$mod] . $encoded; $num = intval($div); } if ($num) $encoded = $alphabet[$num] . $encoded; return $encoded; } function base_decode($num, $alphabet) { $decoded = 0; $multi = 1; while (strlen($num) > 0) { $digit = $num[strlen($num)-1]; $decoded += $multi * strpos($alphabet, $digit); $multi = $multi * strlen($alphabet); $num = substr($num, 0, -1); } return $decoded; } ob_start(); echo base_encode($Guid, $alphabet); //should output: bUKpk $theid = ob_get_contents(); ob_get_clean(); The problem: When i echo $theid, it shows the complete entry, but as it is being inserted into the database, only the first entry in the sequence gets inserted, for example for the entry buKPK, only 'b' is being inserted not the rest.

    Read the article

  • how would you like computer science classes to be taught?

    - by aaa
    hello I am a graduate student now, and hopefully someday I will teach. my interests are C++, Python, embedded languages, and scientific computing. Meanwhile I daydream about how I would teach. I was not quite happy with my undergraduate university as I found many computer science classes lacking. so I would like to ask you, if you were a student, how would you like your computer science classes to be taught? I understand it is a very subjective question, but nevertheless I think it's important to know what people want. Some specific points I am interested in: should computer languages be taught explicitly, or should students be required to pick up language on their own? what is better for learning, tests, projects, some sort of take-home exam? how do you think classtime should be used? theory, introduction, explanations, etc.? do you think the group projects are important? how much about computer architecture do you want to learn in computer science class, not necessarily assembler class. should particular operating system/editor be mandated or encouraged? Thanks thank you for your comments. Question has been closed because it is a discussion question rather than Q&A. If you know appropriate website for discussions of such sort with low noise ratio, please let me know.

    Read the article

  • Unique Alpha numeric generator

    - by AAA
    Hi, I want to give our users in the database a unique alpha-numeric id. I am using the code below, will this always generate a unique id? Below is the updated version of the code: old php: // Generate Guid function NewGuid() { $s = strtoupper(md5(uniqid(rand(),true))); $guidText = substr($s,0,8) . '-' . substr($s,8,4) . '-' . substr($s,12,4). '-' . substr($s,16,4). '-' . substr($s,20); return $guidText; } // End Generate Guid $Guid = NewGuid(); echo $Guid; echo "<br><br><br>"; New PHP: // Generate Guid function NewGuid() { $s = strtoupper(uniqid("something",true)); $guidText = substr($s,0,8) . '-' . substr($s,8,4) . '-' . substr($s,12,4). '-' . substr($s,16,4). '-' . substr($s,20); return $guidText; } // End Generate Guid $Guid = NewGuid(); echo $Guid; echo "<br><br><br>"; Will the second (new php) code guarantee 100% uniqueness. Final code: PHP // Generate Guid function NewGuid() { $s = strtoupper(uniqid(rand(),true)); $guidText = substr($s,0,8) . '-' . substr($s,8,4) . '-' . substr($s,12,4). '-' . substr($s,16,4). '-' . substr($s,20); return $guidText; } // End Generate Guid $Guid = NewGuid(); echo $Guid; $alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'; function base_encode($num, $alphabet) { $base_count = strlen($alphabet); $encoded = ''; while ($num >= $base_count) { $div = $num/$base_count; $mod = ($num-($base_count*intval($div))); $encoded = $alphabet[$mod] . $encoded; $num = intval($div); } if ($num) $encoded = $alphabet[$num] . $encoded; return $encoded; } function base_decode($num, $alphabet) { $decoded = 0; $multi = 1; while (strlen($num) > 0) { $digit = $num[strlen($num)-1]; $decoded += $multi * strpos($alphabet, $digit); $multi = $multi * strlen($alphabet); $num = substr($num, 0, -1); } return $decoded; } echo base_encode($Guid, $alphabet); } So for more stronger uniqueness, i am using the $Guid as the key generator. That should be ok right?

    Read the article

  • gdb stack strangeness

    - by aaa
    Hi I get this weird backtrace (sometimes): (gdb) bt #0 0x00002b36465a5d4c in AY16_Loop_M16 () from /opt/intel/mkl/10.0.3.020/lib/em64t/libmkl_mc.so #1 0x00000000000021da in ?? () #2 0x00000000000021da in ?? () #3 0xbf3e9dec2f04aeff in ?? () #4 0xbf480541bd29306a in ?? () #5 0xbf3e6017955273e8 in ?? () #6 0xbf442b937c2c1f37 in ?? () #7 0x3f5580165832d744 in ?? () ... Any ideas why i cant see the symbols? Compiled with debugging syms of course. The same session gives symbols at other points.

    Read the article

  • Math/numerical formula every computer programmer should know

    - by aaa
    This is a follow-up question to What should every programmer know and Is mathematics necessary. So the question is, as a computer programmer, what is the most important/useful mathematical or numerical formula that you use? By Formula I mean anything that involves less obvious manipulations, whenever binomial coefficients or bit hacks. I work with multidimensional arrays and various matrix representations. So for me most commonly used formulas are: A(i,j,k,..) = a[i + j*Dim0 + k*Dim0*Dim1 + ... to map indexes to one dimension ( which is basic address calculation which many people do not seem to know). And triangular number T(i) = (i*i + i)/2 which is related to binomial coefficients, used to calculate address in triangular matrixes and many other things. What is your workhorse formula that you think programmer should know?

    Read the article

  • C++ boost or STL `y += f(x)` type algorithm

    - by aaa
    hello. I know I can do this y[i] += f(x[i]) using transform with two input iterators. however it seems somewhat counterintuitive and more complicated than for loop. Is there a more natural way to do so using existing algorithm in boost or Stl. I could not find clean equivalent. here is transform (y = y + a*x): using boost::lambda; transform(y.begin(), y.end(), x.begin(), y.begin(), (_1 + scale*_2); // I thought something may exist: transform2(x.begin(), x.end(), y.begin(), (_2 + scale*_1); // it does not, so no biggie. I will write wrapper Thanks

    Read the article

  • C++ code beautifier for emacs/linux

    - by aaa
    hi I am looking for code beautifier for UNIX/emacs. I have looked at gnu indent, artistic style, however I need something a bit different. For example, I would like the following: for( int x= 0;; ++ x) if(x) break; to be formatted as for (int x = 0; ; ++x) if (x) break;. As far as I can tell artistic style does not do that (correct me if I am wrong). What can you recommend? Thanks edit both, artistic style and indent remove whitespace. Here is a small interactive command to beautify region: 405 (defun my-emacs-command-beautify-region() 406 (interactive) 407 (let ((cmd "astyle")) 408 (shell-command-on-region (region-beginning) (region-end) cmd (current-buffer) t))

    Read the article

  • python add two list and createing a new list

    - by Adam G.
    lst1 = ['company1,AAA,7381.0 ', 'company1,BBB,-8333.0 ', 'company1,CCC, 3079.999 ', 'company1,DDD,5699.0 ', 'company1,EEE,1640.0 ', 'company1,FFF,-600.0 ', 'company1,GGG,3822.0 ', 'company1,HHH,-600.0 ', 'company1,JJJ,-4631.0 ', 'company1,KKK,-400.0 '] lst2 =['company1,AAA,-4805.0 ', 'company1,ZZZ,-2576.0 ', 'company1,BBB,1674.0 ', 'company1,CCC,3600.0 ', 'company1,DDD,1743.998 '] output I need == ['company1,AAA,2576.0','company1,ZZZ,-2576.0 ','company1,KKK,-400.0 ' etc etc] I need to add it similar product number in each list and move it to a new list. I also need any symbol not being added together to be added to that new list. I am having problems with moving through each list. This is what I have: h = [] z = [] a = [] for g in hhl: spl1 = g.split(",") h.append(spl1[1]) for j in c_hhl: spl2 = j.split(",") **if spl2[1] in h: converted_num =(float(spl2[2]) +float(spl1[2])) pos=('{0},{1},{2}'.format(spl2[0],spl2[1],converted_num)) z.append(pos)** else: pos=('{0},{1},{2}'.format(spl2[0],spl2[1],spl2[2])) z.append(pos) for f in z: spl3 = f.split(",") a.append(spl3[1]) for n in hhl[:]: spl4 = n.split(",") if spl4[1] in a: got = (spl4[0],spl4[1],spl4[2]) hhl.remove(n) smash = hhl+z #for i in smash: for i in smash: print(i) I am having problem iterating through the list to make sure I get all of the simliar product to a new list,(bold) and any product not in list 1 but in lst2 to the new list and vice versa. I am sure there is a much easier way.

    Read the article

  • emacs, override indentation

    - by aaa
    hi. Hopefully simple question: I have multiply nested namespace: namespace first {namespace second {namespace third { // emacs indents three times // I want to intend here } } } so emacs indents to the third position. However I just want a single indentation. Is it possible to accomplish this effect simply? Thanks

    Read the article

  • C++, LHS state after exception is thrown

    - by aaa
    hi. I am learning C++ exceptions and I would like some clarification of the scenario: T function() throws(std::exception); ... T t = value; try { t = function(); } catch (...) {} if the exception is thrown, what is the state of variable t? unchanged or undefined?

    Read the article

  • simplify expression k/m%n

    - by aaa
    hello. Simple question, is it possible to simplify (or replace division or modulo by less-expensive operation) (k/m)%n where variables are integers and operators are C style division and modulo operators. what about the case where m and n are constants (both or just one), not based 2? Thank you

    Read the article

  • if you have written programming book, what prompted you?

    - by aaa
    I noticed that quite a few authors visit the website. First of all, thank everybody who shared their knowledge. Now the question, what prompted you to write a book? was it desire to educate people, just wanted to write the book, financial gains, something else? was writing a book your idea or you were approached to write the book? were you happy with your final work, after editors have their say what feedback did you receive, positive negative neutral? I am warned this is maybe subjective question, I rest decision to close with moderators.

    Read the article

  • C++ meta-splat function

    - by aaa
    hello. Is there an existing function (in boost mpl or fusion) to splat meta-vector to variadic template arguments? for example: splat<vector<T1, T2, ...>, function>::type same as function<T1, T2, ...> my search have not found one, and I do not want to reinvent one if it already exists. edit: after some tinkering, apparently it's next to impossible to accomplish this in general way, as it would require declaring full template template parameter list for all possible cases. only reasonable solution is to use macro: #define splat(name, function) \ template<class T, ...> struct name; \ template<class T> \ struct name<T,typename boost::enable_if_c< \ result_of::size<T>::value == 1>::type> { \ typedef function< \ typename result_of::value_at_c<T,0>::type \ > type; \ }; Oh well. thank you

    Read the article

  • When to choose C over C++?

    - by aaa
    Hi. I have become a fond of C++ thanks to this website. Before, I programmed exclusively in C/Fortran, thinking that C++ was too slow (not anymore). Is there a reason to write new project purely in C? this is besides obvious things like low-level kernel/system components. What about intermediate things, like communication libraries, for example MPI? Is C still more portable than C++? I have messed with pretty exotic systems, like Cray, but have yet to see non-embedded system without C++. thanks

    Read the article

  • Which namespace does operator<< (stream) go to?

    - by aaa
    If I have have some overloaded ostream operators, defined for library local objects, is its okay for them to go to std namespace? If I do not declare them in std namespace, then I must use using ns:: operator <<. As a possible follow-up question, are there any operators which should go to standard or global namespace?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >