Skip to content

Commit 0235dde

Browse files
committed
Refactor identity
1 parent 44e6a85 commit 0235dde

File tree

5 files changed

+38
-32
lines changed

5 files changed

+38
-32
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ environment:
1515
matrix:
1616
# - GENERATOR: Visual Studio 14 2015
1717

18-
- GENERATOR: Visual Studio 14 2015 Win64
18+
# - GENERATOR: Visual Studio 14 2015 Win64
1919

2020
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
2121
GENERATOR: Visual Studio 15 2017

include/tao/json/byte_view.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,13 @@ namespace tao
337337
}
338338

339339
template< class byteT, int = 1 > // work-around for Visual C++
340-
constexpr bool operator==( basic_byte_view< byteT > x, internal::identity< basic_byte_view< byteT > > y ) noexcept
340+
constexpr bool operator==( basic_byte_view< byteT > x, internal::identity_t< basic_byte_view< byteT > > y ) noexcept
341341
{
342342
return x.compare( y ) == 0;
343343
}
344344

345345
template< class byteT, int = 2 > // work-around for Visual C++
346-
constexpr bool operator==( internal::identity< basic_byte_view< byteT > > x, basic_byte_view< byteT > y ) noexcept
346+
constexpr bool operator==( internal::identity_t< basic_byte_view< byteT > > x, basic_byte_view< byteT > y ) noexcept
347347
{
348348
return x.compare( y ) == 0;
349349
}
@@ -355,13 +355,13 @@ namespace tao
355355
}
356356

357357
template< class byteT, int = 1 > // work-around for Visual C++
358-
constexpr bool operator!=( basic_byte_view< byteT > x, internal::identity< basic_byte_view< byteT > > y ) noexcept
358+
constexpr bool operator!=( basic_byte_view< byteT > x, internal::identity_t< basic_byte_view< byteT > > y ) noexcept
359359
{
360360
return x.compare( y ) != 0;
361361
}
362362

363363
template< class byteT, int = 2 > // work-around for Visual C++
364-
constexpr bool operator!=( internal::identity< basic_byte_view< byteT > > x, basic_byte_view< byteT > y ) noexcept
364+
constexpr bool operator!=( internal::identity_t< basic_byte_view< byteT > > x, basic_byte_view< byteT > y ) noexcept
365365
{
366366
return x.compare( y ) != 0;
367367
}
@@ -373,13 +373,13 @@ namespace tao
373373
}
374374

375375
template< class byteT, int = 1 > // work-around for Visual C++
376-
constexpr bool operator<( basic_byte_view< byteT > x, internal::identity< basic_byte_view< byteT > > y ) noexcept
376+
constexpr bool operator<( basic_byte_view< byteT > x, internal::identity_t< basic_byte_view< byteT > > y ) noexcept
377377
{
378378
return x.compare( y ) < 0;
379379
}
380380

381381
template< class byteT, int = 2 > // work-around for Visual C++
382-
constexpr bool operator<( internal::identity< basic_byte_view< byteT > > x, basic_byte_view< byteT > y ) noexcept
382+
constexpr bool operator<( internal::identity_t< basic_byte_view< byteT > > x, basic_byte_view< byteT > y ) noexcept
383383
{
384384
return x.compare( y ) < 0;
385385
}
@@ -391,13 +391,13 @@ namespace tao
391391
}
392392

393393
template< class byteT, int = 1 > // work-around for Visual C++
394-
constexpr bool operator>( basic_byte_view< byteT > x, internal::identity< basic_byte_view< byteT > > y ) noexcept
394+
constexpr bool operator>( basic_byte_view< byteT > x, internal::identity_t< basic_byte_view< byteT > > y ) noexcept
395395
{
396396
return x.compare( y ) > 0;
397397
}
398398

399399
template< class byteT, int = 2 > // work-around for Visual C++
400-
constexpr bool operator>( internal::identity< basic_byte_view< byteT > > x, basic_byte_view< byteT > y ) noexcept
400+
constexpr bool operator>( internal::identity_t< basic_byte_view< byteT > > x, basic_byte_view< byteT > y ) noexcept
401401
{
402402
return x.compare( y ) > 0;
403403
}
@@ -409,13 +409,13 @@ namespace tao
409409
}
410410

411411
template< class byteT, int = 1 > // work-around for Visual C++
412-
constexpr bool operator<=( basic_byte_view< byteT > x, internal::identity< basic_byte_view< byteT > > y ) noexcept
412+
constexpr bool operator<=( basic_byte_view< byteT > x, internal::identity_t< basic_byte_view< byteT > > y ) noexcept
413413
{
414414
return x.compare( y ) <= 0;
415415
}
416416

417417
template< class byteT, int = 2 > // work-around for Visual C++
418-
constexpr bool operator<=( internal::identity< basic_byte_view< byteT > > x, basic_byte_view< byteT > y ) noexcept
418+
constexpr bool operator<=( internal::identity_t< basic_byte_view< byteT > > x, basic_byte_view< byteT > y ) noexcept
419419
{
420420
return x.compare( y ) <= 0;
421421
}
@@ -427,13 +427,13 @@ namespace tao
427427
}
428428

429429
template< class byteT, int = 1 > // work-around for Visual C++
430-
constexpr bool operator>=( basic_byte_view< byteT > x, internal::identity< basic_byte_view< byteT > > y ) noexcept
430+
constexpr bool operator>=( basic_byte_view< byteT > x, internal::identity_t< basic_byte_view< byteT > > y ) noexcept
431431
{
432432
return x.compare( y ) >= 0;
433433
}
434434

435435
template< class byteT, int = 2 > // work-around for Visual C++
436-
constexpr bool operator>=( internal::identity< basic_byte_view< byteT > > x, basic_byte_view< byteT > y ) noexcept
436+
constexpr bool operator>=( internal::identity_t< basic_byte_view< byteT > > x, basic_byte_view< byteT > y ) noexcept
437437
{
438438
return x.compare( y ) >= 0;
439439
}

include/tao/json/external/string_view.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,13 @@ namespace tao
414414
}
415415

416416
template< class charT, class traits, int = 1 > // work-around for Visual C++
417-
constexpr bool operator==( basic_string_view< charT, traits > x, internal::identity< basic_string_view< charT, traits > > y ) noexcept
417+
constexpr bool operator==( basic_string_view< charT, traits > x, internal::identity_t< basic_string_view< charT, traits > > y ) noexcept
418418
{
419419
return x.compare( y ) == 0;
420420
}
421421

422422
template< class charT, class traits, int = 2 > // work-around for Visual C++
423-
constexpr bool operator==( internal::identity< basic_string_view< charT, traits > > x, basic_string_view< charT, traits > y ) noexcept
423+
constexpr bool operator==( internal::identity_t< basic_string_view< charT, traits > > x, basic_string_view< charT, traits > y ) noexcept
424424
{
425425
return x.compare( y ) == 0;
426426
}
@@ -432,13 +432,13 @@ namespace tao
432432
}
433433

434434
template< class charT, class traits, int = 1 > // work-around for Visual C++
435-
constexpr bool operator!=( basic_string_view< charT, traits > x, internal::identity< basic_string_view< charT, traits > > y ) noexcept
435+
constexpr bool operator!=( basic_string_view< charT, traits > x, internal::identity_t< basic_string_view< charT, traits > > y ) noexcept
436436
{
437437
return x.compare( y ) != 0;
438438
}
439439

440440
template< class charT, class traits, int = 2 > // work-around for Visual C++
441-
constexpr bool operator!=( internal::identity< basic_string_view< charT, traits > > x, basic_string_view< charT, traits > y ) noexcept
441+
constexpr bool operator!=( internal::identity_t< basic_string_view< charT, traits > > x, basic_string_view< charT, traits > y ) noexcept
442442
{
443443
return x.compare( y ) != 0;
444444
}
@@ -450,13 +450,13 @@ namespace tao
450450
}
451451

452452
template< class charT, class traits, int = 1 > // work-around for Visual C++
453-
constexpr bool operator<( basic_string_view< charT, traits > x, internal::identity< basic_string_view< charT, traits > > y ) noexcept
453+
constexpr bool operator<( basic_string_view< charT, traits > x, internal::identity_t< basic_string_view< charT, traits > > y ) noexcept
454454
{
455455
return x.compare( y ) < 0;
456456
}
457457

458458
template< class charT, class traits, int = 2 > // work-around for Visual C++
459-
constexpr bool operator<( internal::identity< basic_string_view< charT, traits > > x, basic_string_view< charT, traits > y ) noexcept
459+
constexpr bool operator<( internal::identity_t< basic_string_view< charT, traits > > x, basic_string_view< charT, traits > y ) noexcept
460460
{
461461
return x.compare( y ) < 0;
462462
}
@@ -468,13 +468,13 @@ namespace tao
468468
}
469469

470470
template< class charT, class traits, int = 1 > // work-around for Visual C++
471-
constexpr bool operator>( basic_string_view< charT, traits > x, internal::identity< basic_string_view< charT, traits > > y ) noexcept
471+
constexpr bool operator>( basic_string_view< charT, traits > x, internal::identity_t< basic_string_view< charT, traits > > y ) noexcept
472472
{
473473
return x.compare( y ) > 0;
474474
}
475475

476476
template< class charT, class traits, int = 2 > // work-around for Visual C++
477-
constexpr bool operator>( internal::identity< basic_string_view< charT, traits > > x, basic_string_view< charT, traits > y ) noexcept
477+
constexpr bool operator>( internal::identity_t< basic_string_view< charT, traits > > x, basic_string_view< charT, traits > y ) noexcept
478478
{
479479
return x.compare( y ) > 0;
480480
}
@@ -486,13 +486,13 @@ namespace tao
486486
}
487487

488488
template< class charT, class traits, int = 1 > // work-around for Visual C++
489-
constexpr bool operator<=( basic_string_view< charT, traits > x, internal::identity< basic_string_view< charT, traits > > y ) noexcept
489+
constexpr bool operator<=( basic_string_view< charT, traits > x, internal::identity_t< basic_string_view< charT, traits > > y ) noexcept
490490
{
491491
return x.compare( y ) <= 0;
492492
}
493493

494494
template< class charT, class traits, int = 2 > // work-around for Visual C++
495-
constexpr bool operator<=( internal::identity< basic_string_view< charT, traits > > x, basic_string_view< charT, traits > y ) noexcept
495+
constexpr bool operator<=( internal::identity_t< basic_string_view< charT, traits > > x, basic_string_view< charT, traits > y ) noexcept
496496
{
497497
return x.compare( y ) <= 0;
498498
}
@@ -504,13 +504,13 @@ namespace tao
504504
}
505505

506506
template< class charT, class traits, int = 1 > // work-around for Visual C++
507-
constexpr bool operator>=( basic_string_view< charT, traits > x, internal::identity< basic_string_view< charT, traits > > y ) noexcept
507+
constexpr bool operator>=( basic_string_view< charT, traits > x, internal::identity_t< basic_string_view< charT, traits > > y ) noexcept
508508
{
509509
return x.compare( y ) >= 0;
510510
}
511511

512512
template< class charT, class traits, int = 2 > // work-around for Visual C++
513-
constexpr bool operator>=( internal::identity< basic_string_view< charT, traits > > x, basic_string_view< charT, traits > y ) noexcept
513+
constexpr bool operator>=( internal::identity_t< basic_string_view< charT, traits > > x, basic_string_view< charT, traits > y ) noexcept
514514
{
515515
return x.compare( y ) >= 0;
516516
}

include/tao/json/internal/identity.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ namespace tao
1111
namespace internal
1212
{
1313
template< typename T >
14-
using identity = typename std::decay< T >::type;
14+
struct identity
15+
{
16+
using type = T;
17+
};
18+
19+
template< typename T >
20+
using identity_t = typename identity< T >::type;
1521

1622
} // namespace internal
1723

include/tao/json/value.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,13 +1590,13 @@ namespace tao
15901590
}
15911591

15921592
template< template< typename... > class Traits, int = 1 > // work-around for Visual C++
1593-
bool operator==( const basic_value< Traits >& lhs, tao::internal::identity< basic_value< Traits > > rhs ) noexcept
1593+
bool operator==( const basic_value< Traits >& lhs, tao::internal::identity_t< basic_value< Traits > > rhs ) noexcept
15941594
{
15951595
return lhs == rhs;
15961596
}
15971597

15981598
template< template< typename... > class Traits, int = 2 > // work-around for Visual C++
1599-
bool operator==( tao::internal::identity< basic_value< Traits > > lhs, const basic_value< Traits >& rhs ) noexcept
1599+
bool operator==( tao::internal::identity_t< basic_value< Traits > > lhs, const basic_value< Traits >& rhs ) noexcept
16001600
{
16011601
return lhs == rhs;
16021602
}
@@ -1783,13 +1783,13 @@ namespace tao
17831783
}
17841784

17851785
template< template< typename... > class Traits, int = 1 > // work-around for Visual C++
1786-
bool operator<( const basic_value< Traits >& lhs, tao::internal::identity< basic_value< Traits > > rhs ) noexcept
1786+
bool operator<( const basic_value< Traits >& lhs, tao::internal::identity_t< basic_value< Traits > > rhs ) noexcept
17871787
{
17881788
return lhs < rhs;
17891789
}
17901790

17911791
template< template< typename... > class Traits, int = 2 > // work-around for Visual C++
1792-
bool operator<( const tao::internal::identity< basic_value< Traits > > lhs, const basic_value< Traits >& rhs ) noexcept
1792+
bool operator<( const tao::internal::identity_t< basic_value< Traits > > lhs, const basic_value< Traits >& rhs ) noexcept
17931793
{
17941794
return lhs < rhs;
17951795
}
@@ -1817,13 +1817,13 @@ namespace tao
18171817
}
18181818

18191819
template< template< typename... > class Traits >
1820-
bool operator>( const basic_value< Traits >& lhs, tao::internal::identity< basic_value< Traits > > rhs ) noexcept
1820+
bool operator>( const basic_value< Traits >& lhs, tao::internal::identity_t< basic_value< Traits > > rhs ) noexcept
18211821
{
18221822
return rhs < lhs;
18231823
}
18241824

18251825
template< template< typename... > class Traits >
1826-
bool operator>( tao::internal::identity< basic_value< Traits > > lhs, const basic_value< Traits >& rhs ) noexcept
1826+
bool operator>( tao::internal::identity_t< basic_value< Traits > > lhs, const basic_value< Traits >& rhs ) noexcept
18271827
{
18281828
return rhs < lhs;
18291829
}

0 commit comments

Comments
 (0)