Changes in src/Common/utility.h [6b0b624:21f0aa8]
- File:
-
- 1 edited
-
src/Common/utility.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/utility.h
r6b0b624 r21f0aa8 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Jul 21 22:19:13201713 // Update Count : 3 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Aug 17 11:38:00 2017 13 // Update Count : 34 14 14 // 15 15 … … 24 24 #include <sstream> 25 25 #include <string> 26 #include <type_traits> 26 27 27 28 #include <cassert> 29 28 30 template< typename T > 29 31 static inline T * maybeClone( const T *orig ) { … … 304 306 // for ( val : group_iterate( container1, container2, ... ) ) {} 305 307 // syntax to have a for each that iterates multiple containers of the same length 306 // TODO: update to use variadic arguments , perfect forwarding308 // TODO: update to use variadic arguments 307 309 308 310 template< typename T1, typename T2 > … … 313 315 314 316 struct iterator { 315 typedef std::tuple<typename T1::value_type, typename T2::value_type> value_type; 316 typedef typename T1::iterator T1Iter; 317 typedef typename T2::iterator T2Iter; 317 typedef typename std::remove_reference<T1>::type T1val; 318 typedef typename std::remove_reference<T2>::type T2val; 319 typedef std::tuple<typename T1val::value_type &, typename T2val::value_type &> value_type; 320 typedef typename T1val::iterator T1Iter; 321 typedef typename T2val::iterator T2Iter; 318 322 typedef std::tuple<T1Iter, T2Iter> IterTuple; 319 323 IterTuple it; … … 323 327 } 324 328 bool operator!=( const iterator &other ) const { return it != other.it; } 325 value_type operator*() const { return std:: make_tuple( *std::get<0>(it), *std::get<1>(it) ); }329 value_type operator*() const { return std::tie( *std::get<0>(it), *std::get<1>(it) ); } 326 330 }; 327 331 iterator begin() { return iterator( std::get<0>(args).begin(), std::get<1>(args).begin() ); } … … 333 337 334 338 template< typename... Args > 335 group_iterate_t<Args...> group_iterate( const Args &... args ) { 336 return group_iterate_t<Args...>(args...); 337 } 338 339 struct CodeLocation { 340 int linenumber; 341 std::string filename; 342 343 /// Create a new unset CodeLocation. 344 CodeLocation() 345 : linenumber( -1 ) 346 , filename("") 347 {} 348 349 /// Create a new CodeLocation with the given values. 350 CodeLocation( const char* filename, int lineno ) 351 : linenumber( lineno ) 352 , filename(filename ? filename : "") 353 {} 354 355 CodeLocation( const CodeLocation& rhs ) = default; 356 357 bool isSet () const { 358 return -1 != linenumber; 359 } 360 361 bool isUnset () const { 362 return !isSet(); 363 } 364 365 void unset () { 366 linenumber = -1; 367 filename = ""; 368 } 369 370 // Use field access for set. 371 }; 372 373 inline std::string to_string( const CodeLocation& location ) { 374 return location.isSet() ? location.filename + ":" + std::to_string(location.linenumber) + " " : ""; 339 group_iterate_t<Args...> group_iterate( Args &&... args ) { 340 return group_iterate_t<Args...>(std::forward<Args>( args )...); 375 341 } 376 342
Note:
See TracChangeset
for help on using the changeset viewer.