Question: I am trying to insert div with iframe before HTML comment (it is the only unique element at this position).

So I have comment like: `<!-- Comment -->` and I would like to insert code like this before the comment:

```
<div id="test">
    <noscript>
      <iframe src="https://test.net" frameborder="0" scrolling="no" width="742" height="92"></iframe>
    </noscript>
</div>

```

I tried methods like .append() and prepend(), but without success.

The result should be:

```
    <div id="test">
        <noscript>
          <iframe src="https://test.net" frameborder="0" scrolling="no" width="742" height="92"></iframe>
        </noscript>
    </div>
<!--  Comment --> 

```

Many thanks for any help!

Answer: 
You can do this in many ways, one of them is the following:

```
template <typename E, typename Enable = void>
struct get_a_int_val {
  static const int value = 42;
};

template <typename E>
struct get_a_int_val<E, typename std::enable_if<std::is_same<decltype(E::a), 
                                                decltype(E::a)>::value, void>::type>{
  static const int value = static_cast<int>(E::a);
};

```

[**LIVE DEMO**](http://coliru.stacked-crooked.com/a/7f7b1705aec30451)
You may create a traits for that:

```
template <typename E>
std::false_type has_a_impl(...);

template <typename E> auto has_a_impl(int) -> decltype(E::a, std::true_type{});

template <typename E>
using has_a = decltype(has_a_impl<E>(0));

```

And then use it in SFINAE:

```
template <typename E>
std::enable_if_t<has_a<E>::value, int>
get_a_int_val() { return static_cast<int>(E::a); }

template <typename E>
std::enable_if_t<!has_a<E>::value, int>
get_a_int_val() { return 42; }

```

[Demo](https://ideone.com/6eq8ML)