Skip to content

Commit

Permalink
c++ apply formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
artemp committed Jun 2, 2016
1 parent 20e44ac commit 372d7c8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion include/mapbox/optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class optional

variant<none_type, T> variant_;

public:
public:
optional() = default;

optional(optional const& rhs)
Expand Down
2 changes: 1 addition & 1 deletion include/mapbox/recursive_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class recursive_wrapper
this->get() = rhs;
}

public:
public:
using type = T;

/**
Expand Down
72 changes: 36 additions & 36 deletions include/mapbox/variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@


#ifdef _MSC_VER
// https://msdn.microsoft.com/en-us/library/bw1hbe6y.aspx
#ifdef NDEBUG
#define VARIANT_INLINE __forceinline
#else
#define VARIANT_INLINE __declspec(noinline)
#endif
// https://msdn.microsoft.com/en-us/library/bw1hbe6y.aspx
# ifdef NDEBUG
# define VARIANT_INLINE __forceinline
# else
# define VARIANT_INLINE //__declspec(noinline)
# endif
#else
#ifdef NDEBUG
#define VARIANT_INLINE inline __attribute__((always_inline))
#else
#define VARIANT_INLINE __attribute__((noinline))
#endif
# ifdef NDEBUG
# define VARIANT_INLINE //inline __attribute__((always_inline))

This comment has been minimized.

Copy link
@jfirebaugh

jfirebaugh Jul 12, 2018

Contributor

@artemp Was it intended to comment this out (and the __declspec(noinline) above)?

This comment has been minimized.

Copy link
@artemp

artemp Jul 13, 2018

Author Contributor

@jfirebaugh - hmm, I'm struggling to remember exact details. It could've been some weird compiler combo..or more likely I pushed my local changes by mistake. Feel free to add them back if it makes sense.

# else
# define VARIANT_INLINE __attribute__((noinline))
# endif
#endif
// clang-format on

Expand All @@ -58,7 +58,7 @@ namespace util {
class bad_variant_access : public std::runtime_error
{

public:
public:
explicit bad_variant_access(const std::string& what_arg)
: runtime_error(what_arg) {}

Expand All @@ -72,7 +72,7 @@ struct MAPBOX_VARIANT_DEPRECATED static_visitor
{
using result_type = R;

protected:
protected:
static_visitor() {}
~static_visitor() {}
};
Expand All @@ -88,8 +88,8 @@ template <typename T, typename First, typename... Types>
struct direct_type<T, First, Types...>
{
static constexpr std::size_t index = std::is_same<T, First>::value
? sizeof...(Types)
: direct_type<T, Types...>::index;
? sizeof...(Types)
: direct_type<T, Types...>::index;
};

template <typename T>
Expand All @@ -105,8 +105,8 @@ template <typename T, typename First, typename... Types>
struct convertible_type<T, First, Types...>
{
static constexpr std::size_t index = std::is_convertible<T, First>::value
? sizeof...(Types)
: convertible_type<T, Types...>::index;
? sizeof...(Types)
: convertible_type<T, Types...>::index;
};

template <typename T>
Expand Down Expand Up @@ -490,7 +490,7 @@ struct less_comp
template <typename Variant, typename Comp>
class comparer
{
public:
public:
explicit comparer(Variant const& lhs) noexcept
: lhs_(lhs) {}
comparer& operator=(comparer const&) = delete;
Expand All @@ -502,7 +502,7 @@ class comparer
return Comp()(lhs_content, rhs_content);
}

private:
private:
Variant const& lhs_;
};

Expand Down Expand Up @@ -532,7 +532,7 @@ class variant
static_assert(sizeof...(Types) > 0, "Template parameter type list of variant can not be empty");
static_assert(detail::static_none_of<std::is_reference, Types...>::value, "Variant can not hold reference types. Maybe use std::reference?");

private:
private:
static const std::size_t data_size = detail::static_max<sizeof(Types)...>::value;
static const std::size_t data_align = detail::static_max<alignof(Types)...>::value;

Expand All @@ -543,7 +543,7 @@ class variant
std::size_t type_index;
data_type data;

public:
public:
VARIANT_INLINE variant() noexcept(std::is_nothrow_default_constructible<first_type>::value)
: type_index(sizeof...(Types)-1)
{
Expand Down Expand Up @@ -575,7 +575,7 @@ class variant
helper_type::move(old.type_index, &old.data, &data);
}

private:
private:
VARIANT_INLINE void copy_assign(variant<Types...> const& rhs)
{
helper_type::destroy(type_index, &data);
Expand All @@ -592,7 +592,7 @@ class variant
type_index = rhs.type_index;
}

public:
public:
VARIANT_INLINE variant<Types...>& operator=(variant<Types...>&& other)
{
move_assign(std::move(other));
Expand Down Expand Up @@ -654,7 +654,7 @@ class variant

// get_unchecked<T>()
template <typename T, typename std::enable_if<
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get_unchecked()
{
return *reinterpret_cast<T*>(&data);
Expand All @@ -663,7 +663,7 @@ class variant
#ifdef __EXCEPTIONS
// get<T>()
template <typename T, typename std::enable_if<
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get()
{
if (type_index == detail::direct_type<T, Types...>::index)
Expand All @@ -678,15 +678,15 @@ class variant
#endif

template <typename T, typename std::enable_if<
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get_unchecked() const
{
return *reinterpret_cast<T const*>(&data);
}

#ifdef __EXCEPTIONS
template <typename T, typename std::enable_if<
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get() const
{
if (type_index == detail::direct_type<T, Types...>::index)
Expand All @@ -702,7 +702,7 @@ class variant

// get_unchecked<T>() - T stored as recursive_wrapper<T>
template <typename T, typename std::enable_if<
(detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
(detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get_unchecked()
{
return (*reinterpret_cast<recursive_wrapper<T>*>(&data)).get();
Expand All @@ -711,7 +711,7 @@ class variant
#ifdef __EXCEPTIONS
// get<T>() - T stored as recursive_wrapper<T>
template <typename T, typename std::enable_if<
(detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
(detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get()
{
if (type_index == detail::direct_type<recursive_wrapper<T>, Types...>::index)
Expand All @@ -726,15 +726,15 @@ class variant
#endif

template <typename T, typename std::enable_if<
(detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
(detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get_unchecked() const
{
return (*reinterpret_cast<recursive_wrapper<T> const*>(&data)).get();
}

#ifdef __EXCEPTIONS
template <typename T, typename std::enable_if<
(detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
(detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get() const
{
if (type_index == detail::direct_type<recursive_wrapper<T>, Types...>::index)
Expand All @@ -750,7 +750,7 @@ class variant

// get_unchecked<T>() - T stored as std::reference_wrapper<T>
template <typename T, typename std::enable_if<
(detail::direct_type<std::reference_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
(detail::direct_type<std::reference_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get_unchecked()
{
return (*reinterpret_cast<std::reference_wrapper<T>*>(&data)).get();
Expand All @@ -759,7 +759,7 @@ class variant
#ifdef __EXCEPTIONS
// get<T>() - T stored as std::reference_wrapper<T>
template <typename T, typename std::enable_if<
(detail::direct_type<std::reference_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
(detail::direct_type<std::reference_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get()
{
if (type_index == detail::direct_type<std::reference_wrapper<T>, Types...>::index)
Expand All @@ -774,15 +774,15 @@ class variant
#endif

template <typename T, typename std::enable_if<
(detail::direct_type<std::reference_wrapper<T const>, Types...>::index != detail::invalid_value)>::type* = nullptr>
(detail::direct_type<std::reference_wrapper<T const>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get_unchecked() const
{
return (*reinterpret_cast<std::reference_wrapper<T const> const*>(&data)).get();
}

#ifdef __EXCEPTIONS
template <typename T, typename std::enable_if<
(detail::direct_type<std::reference_wrapper<T const>, Types...>::index != detail::invalid_value)>::type* = nullptr>
(detail::direct_type<std::reference_wrapper<T const>, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get() const
{
if (type_index == detail::direct_type<std::reference_wrapper<T const>, Types...>::index)
Expand All @@ -809,7 +809,7 @@ class variant
}

template <typename T, typename std::enable_if<
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE static constexpr int which() noexcept
{
return static_cast<int>(sizeof...(Types)-detail::direct_type<T, Types...>::index - 1);
Expand Down
4 changes: 2 additions & 2 deletions include/mapbox/variant_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace detail {
template <typename Out>
class printer
{
public:
public:
explicit printer(Out& out)
: out_(out) {}
printer& operator=(printer const&) = delete;
Expand All @@ -25,7 +25,7 @@ class printer
out_ << operand;
}

private:
private:
Out& out_;
};
}
Expand Down

0 comments on commit 372d7c8

Please sign in to comment.