Skip to content

Commit 4c91ed2

Browse files
committed
🔀 Add visibility attributes
This adds attributes for the visibility to all function definitions in Backport. This ensures that symbols will not be looked up when used in a library, and attempts to insure proper inline definitions that won't be used during profiling.
2 parents 60b534b + 016327c commit 4c91ed2

17 files changed

+750
-438
lines changed

include/bpstd/any.hpp

+63-31
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
# pragma once
3535
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
3636

37+
#include "detail/config.hpp"
3738
#include "type_traits.hpp" // enable_if_t, is_*
3839
#include "utility.hpp" // in_place_type_t, move, forward
3940

@@ -331,7 +332,8 @@ namespace bpstd {
331332
// definitions : class : bad_any_cast
332333
//=============================================================================
333334

334-
inline const char* bpstd::bad_any_cast::what()
335+
inline
336+
const char* bpstd::bad_any_cast::what()
335337
const noexcept
336338
{
337339
return "bad_any_cast";
@@ -363,30 +365,34 @@ struct bpstd::any::internal_storage_handler
363365

364366
template<typename T>
365367
template<typename...Args>
366-
inline T* bpstd::any::internal_storage_handler<T>
368+
inline BPSTD_INLINE_VISIBILITY
369+
T* bpstd::any::internal_storage_handler<T>
367370
::construct(storage& s, Args&&...args)
368371
{
369372
return ::new(&s.internal) T(bpstd::forward<Args>(args)...);
370373
}
371374

372375
template<typename T>
373376
template<typename U, typename...Args>
374-
inline T* bpstd::any::internal_storage_handler<T>
377+
inline BPSTD_INLINE_VISIBILITY
378+
T* bpstd::any::internal_storage_handler<T>
375379
::construct(storage& s, std::initializer_list<U> il, Args&&...args)
376380
{
377381
return ::new(&s.internal) T(il, bpstd::forward<Args>(args)...);
378382
}
379383

380384
template<typename T>
381-
inline void bpstd::any::internal_storage_handler<T>
385+
inline BPSTD_INLINE_VISIBILITY
386+
void bpstd::any::internal_storage_handler<T>
382387
::destroy(storage& s)
383388
{
384389
auto* t = static_cast<T*>(static_cast<void*>(&s.internal));
385390
t->~T();
386391
}
387392

388393
template<typename T>
389-
inline const void* bpstd::any::internal_storage_handler<T>
394+
inline BPSTD_INLINE_VISIBILITY
395+
const void* bpstd::any::internal_storage_handler<T>
390396
::handle(operation op,
391397
const storage* self,
392398
const storage* other)
@@ -476,7 +482,8 @@ struct bpstd::any::external_storage_handler
476482

477483
template<typename T>
478484
template<typename...Args>
479-
inline T* bpstd::any::external_storage_handler<T>
485+
inline BPSTD_INLINE_VISIBILITY
486+
T* bpstd::any::external_storage_handler<T>
480487
::construct(storage& s, Args&&...args)
481488
{
482489
s.external = new T(bpstd::forward<Args>(args)...);
@@ -485,22 +492,25 @@ inline T* bpstd::any::external_storage_handler<T>
485492

486493
template<typename T>
487494
template<typename U, typename...Args>
488-
inline T* bpstd::any::external_storage_handler<T>
495+
inline BPSTD_INLINE_VISIBILITY
496+
T* bpstd::any::external_storage_handler<T>
489497
::construct(storage& s, std::initializer_list<U> il, Args&&...args)
490498
{
491499
s.external = new T(il, bpstd::forward<Args>(args)...);
492500
return static_cast<T*>(s.external);
493501
}
494502

495503
template<typename T>
496-
inline void bpstd::any::external_storage_handler<T>
504+
inline BPSTD_INLINE_VISIBILITY
505+
void bpstd::any::external_storage_handler<T>
497506
::destroy(storage& s)
498507
{
499508
delete static_cast<T*>(s.external);
500509
}
501510

502511
template<typename T>
503-
inline const void* bpstd::any::external_storage_handler<T>
512+
inline BPSTD_INLINE_VISIBILITY
513+
const void* bpstd::any::external_storage_handler<T>
504514
::handle( operation op,
505515
const storage* self,
506516
const storage* other )
@@ -567,15 +577,17 @@ inline const void* bpstd::any::external_storage_handler<T>
567577
// Constructors / Destructor / Assignment
568578
//-----------------------------------------------------------------------------
569579

570-
inline bpstd::any::any()
580+
inline BPSTD_INLINE_VISIBILITY
581+
bpstd::any::any()
571582
noexcept
572583
: m_storage{},
573584
m_storage_handler{nullptr}
574585
{
575586

576587
}
577588

578-
inline bpstd::any::any(any&& other)
589+
inline BPSTD_INLINE_VISIBILITY
590+
bpstd::any::any(any&& other)
579591
noexcept
580592
: m_storage{},
581593
m_storage_handler{other.m_storage_handler}
@@ -585,7 +597,8 @@ inline bpstd::any::any(any&& other)
585597
}
586598
}
587599

588-
inline bpstd::any::any(const any& other)
600+
inline BPSTD_INLINE_VISIBILITY
601+
bpstd::any::any(const any& other)
589602
: m_storage{},
590603
m_storage_handler{nullptr}
591604
{
@@ -600,7 +613,8 @@ inline bpstd::any::any(const any& other)
600613
}
601614

602615
template<typename ValueType, typename>
603-
inline bpstd::any::any(ValueType&& value)
616+
inline BPSTD_INLINE_VISIBILITY
617+
bpstd::any::any(ValueType&& value)
604618
: m_storage{},
605619
m_storage_handler{nullptr}
606620
{
@@ -612,7 +626,8 @@ inline bpstd::any::any(ValueType&& value)
612626
}
613627

614628
template<typename ValueType, typename...Args, typename>
615-
inline bpstd::any::any(in_place_type_t<ValueType>, Args&&...args)
629+
inline BPSTD_INLINE_VISIBILITY
630+
bpstd::any::any(in_place_type_t<ValueType>, Args&&...args)
616631
: m_storage{},
617632
m_storage_handler{nullptr}
618633
{
@@ -624,7 +639,8 @@ inline bpstd::any::any(in_place_type_t<ValueType>, Args&&...args)
624639
}
625640

626641
template<typename ValueType, typename U, typename...Args, typename>
627-
inline bpstd::any::any(in_place_type_t<ValueType>,
642+
inline BPSTD_INLINE_VISIBILITY
643+
bpstd::any::any(in_place_type_t<ValueType>,
628644
std::initializer_list<U> il,
629645
Args&&...args)
630646
: m_storage{},
@@ -639,14 +655,16 @@ inline bpstd::any::any(in_place_type_t<ValueType>,
639655

640656
//-----------------------------------------------------------------------------
641657

642-
inline bpstd::any::~any()
658+
inline BPSTD_INLINE_VISIBILITY
659+
bpstd::any::~any()
643660
{
644661
reset();
645662
}
646663

647664
//-----------------------------------------------------------------------------
648665

649-
inline bpstd::any& bpstd::any::operator=(any&& other)
666+
inline BPSTD_INLINE_VISIBILITY
667+
bpstd::any& bpstd::any::operator=(any&& other)
650668
noexcept
651669
{
652670
reset();
@@ -659,7 +677,8 @@ inline bpstd::any& bpstd::any::operator=(any&& other)
659677
return (*this);
660678
}
661679

662-
inline bpstd::any& bpstd::any::operator=(const any& other)
680+
inline BPSTD_INLINE_VISIBILITY
681+
bpstd::any& bpstd::any::operator=(const any& other)
663682
{
664683
reset();
665684

@@ -675,7 +694,8 @@ inline bpstd::any& bpstd::any::operator=(const any& other)
675694
}
676695

677696
template<typename ValueType, typename>
678-
inline bpstd::any& bpstd::any::operator=(ValueType&& value)
697+
inline BPSTD_INLINE_VISIBILITY
698+
bpstd::any& bpstd::any::operator=(ValueType&& value)
679699
{
680700
using handler_type = storage_handler<decay_t<ValueType>>;
681701

@@ -692,7 +712,8 @@ inline bpstd::any& bpstd::any::operator=(ValueType&& value)
692712
//-----------------------------------------------------------------------------
693713

694714
template<typename ValueType, typename...Args, typename>
695-
inline bpstd::decay_t<ValueType>&
715+
inline BPSTD_INLINE_VISIBILITY
716+
bpstd::decay_t<ValueType>&
696717
bpstd::any::emplace(Args&&...args)
697718
{
698719
using handler_type = storage_handler<decay_t<ValueType>>;
@@ -707,7 +728,8 @@ inline bpstd::decay_t<ValueType>&
707728
}
708729

709730
template<typename ValueType, typename U, typename...Args, typename>
710-
inline bpstd::decay_t<ValueType>&
731+
inline BPSTD_INLINE_VISIBILITY
732+
bpstd::decay_t<ValueType>&
711733
bpstd::any::emplace(std::initializer_list<U> il,
712734
Args&&...args)
713735
{
@@ -723,7 +745,8 @@ inline bpstd::decay_t<ValueType>&
723745
return result;
724746
}
725747

726-
inline void bpstd::any::reset()
748+
inline BPSTD_INLINE_VISIBILITY
749+
void bpstd::any::reset()
727750
noexcept
728751
{
729752
if (m_storage_handler != nullptr) {
@@ -732,7 +755,8 @@ inline void bpstd::any::reset()
732755
}
733756
}
734757

735-
inline void bpstd::any::swap(any& other)
758+
inline BPSTD_INLINE_VISIBILITY
759+
void bpstd::any::swap(any& other)
736760
noexcept
737761
{
738762
using std::swap;
@@ -777,13 +801,15 @@ inline void bpstd::any::swap(any& other)
777801
// Observers
778802
//-----------------------------------------------------------------------------
779803

780-
inline bool bpstd::any::has_value()
804+
inline BPSTD_INLINE_VISIBILITY
805+
bool bpstd::any::has_value()
781806
const noexcept
782807
{
783808
return m_storage_handler != nullptr;
784809
}
785810

786-
inline const std::type_info& bpstd::any::type()
811+
inline BPSTD_INLINE_VISIBILITY
812+
const std::type_info& bpstd::any::type()
787813
const noexcept
788814
{
789815
if (has_value()) {
@@ -801,7 +827,8 @@ inline const std::type_info& bpstd::any::type()
801827
// utilities
802828
//-----------------------------------------------------------------------------
803829

804-
inline void bpstd::swap(any& lhs, any& rhs)
830+
inline BPSTD_INLINE_VISIBILITY
831+
void bpstd::swap(any& lhs, any& rhs)
805832
noexcept
806833
{
807834
lhs.swap(rhs);
@@ -812,7 +839,8 @@ inline void bpstd::swap(any& lhs, any& rhs)
812839
//-----------------------------------------------------------------------------
813840

814841
template<typename T>
815-
inline T bpstd::any_cast(any& operand)
842+
inline BPSTD_INLINE_VISIBILITY
843+
T bpstd::any_cast(any& operand)
816844
{
817845
auto* p = any_cast<T>(&operand);
818846
if (p == nullptr) {
@@ -822,7 +850,8 @@ inline T bpstd::any_cast(any& operand)
822850
}
823851

824852
template<typename T>
825-
inline T bpstd::any_cast(any&& operand)
853+
inline BPSTD_INLINE_VISIBILITY
854+
T bpstd::any_cast(any&& operand)
826855
{
827856
auto* p = any_cast<T>(&operand);
828857
if (p == nullptr) {
@@ -832,7 +861,8 @@ inline T bpstd::any_cast(any&& operand)
832861
}
833862

834863
template<typename T>
835-
inline T bpstd::any_cast(const any& operand)
864+
inline BPSTD_INLINE_VISIBILITY
865+
T bpstd::any_cast(const any& operand)
836866
{
837867
auto* p = any_cast<T>(&operand);
838868
if (p == nullptr) {
@@ -842,7 +872,8 @@ inline T bpstd::any_cast(const any& operand)
842872
}
843873

844874
template<typename T>
845-
inline T* bpstd::any_cast(any* operand)
875+
inline BPSTD_INLINE_VISIBILITY
876+
T* bpstd::any_cast(any* operand)
846877
noexcept
847878
{
848879
if (!operand) {
@@ -859,7 +890,8 @@ inline T* bpstd::any_cast(any* operand)
859890
}
860891

861892
template<typename T>
862-
inline const T* bpstd::any_cast(const any* operand)
893+
inline BPSTD_INLINE_VISIBILITY
894+
const T* bpstd::any_cast(const any* operand)
863895
noexcept
864896
{
865897
if (!operand) {

0 commit comments

Comments
 (0)