@@ -1438,21 +1438,21 @@ namespace variant_detail
1438
1438
}
1439
1439
}
1440
1440
1441
- template <int N,typename Json,typename Variant,typename ... Args>
1441
+ template <int N,typename Json,typename Variant,Alloc,TempAlloc,VariantTypes, typename ... Args>
1442
1442
typename std::enable_if<N == std::variant_size_v<Variant>, conversion_result<Variant>>::type
1443
- as_variant (const Json& /* j*/ )
1443
+ as_variant (const allocator_set<Alloc,TempAlloc>&, const Json& /* j*/ )
1444
1444
{
1445
1445
return conversion_result<Variant>(jsoncons::unexpect, conv_errc::not_variant);
1446
1446
}
1447
1447
1448
- template <std::size_t N,typename Json,typename Variant,typename T,typename ... U>
1448
+ template <std::size_t N,typename Json,typename Variant,Alloc,TempAlloc,VariantTypes, typename T,typename ... U>
1449
1449
typename std::enable_if<N < std::variant_size_v<Variant>, conversion_result<Variant>>::type
1450
- as_variant (const Json& j)
1450
+ as_variant (const allocator_set<Alloc,TempAlloc>& aset, const Json& j)
1451
1451
{
1452
1452
using result_type = conversion_result<Variant>;
1453
1453
if (j.template is <T>())
1454
1454
{
1455
- auto res = j.template try_as <T>();
1455
+ auto res = j.template try_as <T>(aset );
1456
1456
if (JSONCONS_UNLIKELY (!res))
1457
1457
{
1458
1458
return result_type (jsoncons::unexpect, conv_errc::not_variant);
@@ -1494,9 +1494,9 @@ namespace variant_detail
1494
1494
}
1495
1495
1496
1496
template <typename Alloc, typename TempAlloc>
1497
- static result_type try_as (const allocator_set<Alloc,TempAlloc>&, const Json& j)
1497
+ static result_type try_as (const allocator_set<Alloc,TempAlloc>& aset , const Json& j)
1498
1498
{
1499
- return result_type (variant_detail::as_variant<0 ,Json,variant_type, VariantTypes...>(j));
1499
+ return result_type (variant_detail::as_variant<0 ,Json,variant_type,Alloc,TempAlloc, VariantTypes...>(aset, j));
1500
1500
}
1501
1501
1502
1502
template <typename Alloc>
@@ -1528,21 +1528,21 @@ namespace variant_detail
1528
1528
}
1529
1529
1530
1530
template <typename Alloc, typename TempAlloc>
1531
- static result_type try_as (const allocator_set<Alloc,TempAlloc>&, const Json& j)
1531
+ static result_type try_as (const allocator_set<Alloc,TempAlloc>& aset , const Json& j)
1532
1532
{
1533
- return from_json_ (j);
1533
+ return from_json_ (aset, j);
1534
1534
}
1535
1535
1536
1536
template <typename Alloc>
1537
- static Json to_json (const duration_type& val, const Alloc&)
1537
+ static Json to_json (const duration_type& val, const Alloc& alloc )
1538
1538
{
1539
- return to_json_ (val);
1539
+ return to_json_ (val, alloc );
1540
1540
}
1541
1541
1542
- template <typename PeriodT=Period>
1542
+ template <typename Alloc, typename TempAlloc, typename PeriodT=Period>
1543
1543
static
1544
1544
typename std::enable_if<std::is_same<PeriodT,std::ratio<1 >>::value, result_type>::type
1545
- from_json_ (const Json& j)
1545
+ from_json_ (const allocator_set<Alloc,TempAlloc>& aset, const Json& j)
1546
1546
{
1547
1547
if (j.is_int64 () || j.is_uint64 () || j.is_double ())
1548
1548
{
@@ -1598,7 +1598,7 @@ namespace variant_detail
1598
1598
}
1599
1599
default :
1600
1600
{
1601
- auto res = j.template try_as <Rep>();
1601
+ auto res = j.template try_as <Rep>(aset );
1602
1602
if (!res)
1603
1603
{
1604
1604
return result_type (unexpect, conv_errc::not_epoch);
@@ -1613,10 +1613,10 @@ namespace variant_detail
1613
1613
}
1614
1614
}
1615
1615
1616
- template <typename PeriodT=Period>
1616
+ template <typename Alloc, typename TempAlloc, typename PeriodT=Period>
1617
1617
static
1618
1618
typename std::enable_if<std::is_same<PeriodT,std::milli>::value, result_type>::type
1619
- from_json_ (const Json& j)
1619
+ from_json_ (const allocator_set<Alloc,TempAlloc>& aset, const Json& j)
1620
1620
{
1621
1621
if (j.is_int64 () || j.is_uint64 ())
1622
1622
{
@@ -1698,7 +1698,7 @@ namespace variant_detail
1698
1698
}
1699
1699
default :
1700
1700
{
1701
- auto res = j.template try_as <Rep>();
1701
+ auto res = j.template try_as <Rep>(aset );
1702
1702
if (!res)
1703
1703
{
1704
1704
return result_type (unexpect, conv_errc::not_epoch);
@@ -1713,10 +1713,10 @@ namespace variant_detail
1713
1713
}
1714
1714
}
1715
1715
1716
- template <typename PeriodT=Period>
1716
+ template <typename Alloc, typename TempAlloc, typename PeriodT=Period>
1717
1717
static
1718
1718
typename std::enable_if<std::is_same<PeriodT,std::nano>::value, result_type>::type
1719
- from_json_ (const Json& j)
1719
+ from_json_ (const allocator_set<Alloc,TempAlloc>& aset, const Json& j)
1720
1720
{
1721
1721
if (j.is_int64 () || j.is_uint64 () || j.is_double ())
1722
1722
{
@@ -1750,7 +1750,7 @@ namespace variant_detail
1750
1750
}
1751
1751
else if (j.is_string ())
1752
1752
{
1753
- auto res = j.template try_as <Rep>();
1753
+ auto res = j.template try_as <Rep>(aset );
1754
1754
if (!res)
1755
1755
{
1756
1756
return result_type (unexpect, conv_errc::not_epoch);
@@ -1773,28 +1773,28 @@ namespace variant_detail
1773
1773
}
1774
1774
}
1775
1775
1776
- template <typename PeriodT=Period>
1776
+ template <typename Alloc, typename PeriodT=Period>
1777
1777
static
1778
1778
typename std::enable_if<std::is_same<PeriodT,std::ratio<1 >>::value,Json>::type
1779
- to_json_ (const duration_type& val)
1779
+ to_json_ (const duration_type& val, const Alloc& alloc )
1780
1780
{
1781
- return Json ( val.count (), semantic_tag::epoch_second);
1781
+ return make_json_using_allocator< Json>(alloc, val.count (), semantic_tag::epoch_second);
1782
1782
}
1783
1783
1784
- template <typename PeriodT=Period>
1784
+ template <typename Alloc, typename PeriodT=Period>
1785
1785
static
1786
1786
typename std::enable_if<std::is_same<PeriodT,std::milli>::value,Json>::type
1787
- to_json_ (const duration_type& val)
1787
+ to_json_ (const duration_type& val, const Alloc& alloc )
1788
1788
{
1789
- return Json ( val.count (), semantic_tag::epoch_milli);
1789
+ return make_json_using_allocator< Json>(alloc, val.count (), semantic_tag::epoch_milli);
1790
1790
}
1791
1791
1792
- template <typename PeriodT=Period>
1792
+ template <typename Alloc, typename PeriodT=Period>
1793
1793
static
1794
1794
typename std::enable_if<std::is_same<PeriodT,std::nano>::value,Json>::type
1795
- to_json_ (const duration_type& val)
1795
+ to_json_ (const duration_type& val, const Alloc& alloc )
1796
1796
{
1797
- return Json ( val.count (), semantic_tag::epoch_nano);
1797
+ return make_json_using_allocator< Json>(alloc, val.count (), semantic_tag::epoch_nano);
1798
1798
}
1799
1799
};
1800
1800
0 commit comments